$ .getJSON (jQuery) not working in IE 8

There is simple AJAX code that works in Firefox and Chrome, but not in IE. I am not doing anything, but the code is too long to post here.

Essentially this:

<script type="text/javascript">
var baseurl = 'http://mydomain.com/facebook/';
 var setUpGame = function(lvl){
  var ajaxurl;
  ajaxurl = baseurl+'ajax.php?f=gg&l='+lvl;
  $.getJSON(ajaxurl,function(data){
                   //do stuff with data here
  });
 };
 $(document).ready(function(){
  setUpGame(3);
 });
</script>  

The problem is that IE has a problem with $ .getJSON. The call stack shows that it does not work in the bowels of jQuery (row 123, column 183), where the jQuery code reads "return new A.XMLHttpRequest"

Error message: "Error: The object does not support this property or method." I checked that the ajaxurl variable has the correct value and this URL returns the correct JSON.

Could this happen because it all works inside the iFrame?

+3
source share
2

, , , , - .

, IE XMLHttpRequest.

, , .

:

  • jQuery.support.cors = true; .

  • JSONP , . , , , ... .

  • $. getScript , json, . "dataType" script ' XDomain, .success.

  • $. getJSON IE8 - " ". CORS. .

, , :

$.ajax({ 
    url : remote_cross_domain_non_local_url,
    dataType : 'jsonp'
})
.success( function(data){ dosomethingwithdata(data); } );

, jsonp, -. XDomain IE, , , JSONP script.

+3

jQuery 1.4.2 1.3.2, .

+1
source

Source: https://habr.com/ru/post/1752554/


All Articles