I apologize if my English is not perfect, because I see that I am not clear enough ... One of my main problems is explained by another person here: http: // http: //forum.jquery.com/topic/cross-domain- ajax-and-ie
So what is the alternative?
1) XDomainRequest
Personally, I think this is the best way to implement cross-site scripting in IE8 + (since it is natively supported). The only problem is only Microsoft. But, like many other things with the IE family, we can easily extend the functionality of jQuery ajax.
According to the documentation, you need to specify some additional headers in domain1.tld, for example, in PHP as follows:
header("Access-Control-Allow-Origin: http://domain2.tld"); //use * for any
Perhaps the following alternative is useful for providing a jQuery XDomainRequest implementation;
Update (a): There is an XDR library (not jquery) that "replaces" the XHR class to make it a cross browser, it is based on the pmxdr client library . I have not tried it yet.
2) CORS
The only problem with this plugin is that it is not just an extension, since its functions are called differently, so you need to either change your codes or wrap this plugin.
Update (b): I modified the CORS plugin to simplify it. Check out my other answer to get the code.
3) JsonP in jQuery
This should be the easiest way to solve my problem (since I have control over both servers). In fact, most browsers support cross-site scripting only if the json format is used (I believe xml can also be used). In this case, the function $ .getJSON () is used. To make it work, you need to specify (as indicated in the documentation) callback =? in the URL, for example:
$.getJSON("http://domain2.tld/index.php?callback=?",funciton(res){ ... });
"?" after the "callback" is replaced by an identifier ... in your php file, you need to get this identifier and surround the Json code as follows:
print_r($_GET["callback"])."(".json_encode($mydata).");";
(I got this example from here )
The problem with this method is that if you want to get only HTML, it should be inside the json object and thus make the process a bit more complicated and overwhelming.
4) jquery.jsonp plugin
If you need additional checks and functions to support inline JSONP in jQuery, try this plugin, which will also simplify the process.
5) xdomainajax
This plugin uses an interesting aproach using the YQL service of Yahoo, in which any web page (or part of it) can be converted to Json, which allows you to import it into javascript. This method is good for situations in which you cannot change the format of the original.
6) flXHR
This solution uses flash (swf) to achieve magic. I can say that this is a very fast way to achieve an almost complete cross-browser implementation (since it relies on flash support). This method may be ideal for sites where the flash will be present (for sure). However, if your site does not require flash memory, then this will become a major drawback, as users must have flash installed in order for this to work.
7) xdajax
This solution is based on the implementation of YUI along with the Flash approach.
8) If none of the previous options is suitable for you, remember that you can still use the old trick to insert a tag to import JS code.
9) Reducing IE security to a minimum also solves the problem. But I think it would be nice to have this message: "Please lower your security settings to use this site" ... lol
Hope this helps others in a similar situation.