AJAX Cross-Domain problem
Asked Answered
S

1

5

I have following problem. My webapp is running at

http://webapp.mysite.com/browser/

And I want to make a request to

http://mysite.com/request?....

If I make a standart ajax call with the second url I get an error message , domain (same-origin) policy error.

 [object Object]-error-[Exception... 
  "Component returned failure code: 0x80004005 
  (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]"
   nsresult: "0x80004005 (NS_ERROR_FAILURE)"  
   location: "JS frame :: ..../scripts/jquery/js/jquery-1.4.4.min.js ::
   anonymous :: line 16"  data: no]

Now I tried this ajax php proxy to solve my problem. But the scripts returns no content.

var app = 'http://www.mysite.com/rest.php?request=credits';
var proxy = 'proxy.php?proxy_url=' + app;

$.ajax({
    url: proxy,
    cache: false,
    async: false,
    dataType: 'html'
    success: function(html){
         alert(html);
    },
    error: function(){

    }
});

Any ideas?

Shading answered 27/2, 2011 at 14:54 Comment(1)
What's going on the server-side? Is the server side called? I think you have to search the problem on the server. Is the script called? What 's the content of $h->body?Conduce
C
8

Ah, perhaps this is the problem:

http://api.jquery.com/jQuery.ajax/

"Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation."

And you said, you will use cross-domain requests, so you can not set async to false. Please try it with async = true and give feedback.

Ah, and do you get an alert message with empty content?

Conduce answered 27/2, 2011 at 15:8 Comment(1)
I use it for validation so async needs to be false. yes I get an emtpy alert messageShading

© 2022 - 2024 — McMap. All rights reserved.