I am using following code to grab data from JSON.
$(document).ready(function()
{
$.getJSON(".php?id=113&out=json", function(data) {
$.each(data.issue.page, function(i,item) {
imagesJSON[i] = item["@attributes"];
});
alert(imagesJSON.length);
});
});
It works in Mozilla, Chrome and other browser but not in IE. (Not in any Version).
I am using following code to grab data from JSON.
$(document).ready(function()
{
$.getJSON("http://www.example.com/data.php?id=113&out=json", function(data) {
$.each(data.issue.page, function(i,item) {
imagesJSON[i] = item["@attributes"];
});
alert(imagesJSON.length);
});
});
It works in Mozilla, Chrome and other browser but not in IE. (Not in any Version).
Share Improve this question edited May 4, 2019 at 3:43 Cœur 38.7k26 gold badges202 silver badges277 bronze badges asked Apr 25, 2012 at 12:04 user1199138user1199138 10 | Show 5 more comments2 Answers
Reset to default 18$.getJSON
has a tendency to cache results in IE. Use $.ajax
instead.
The related call should be something like this in your case:
// Not really sure if you've forgot to var
var imagesJSON = [];
$.ajax({
url: "www.example.com/data.php?id=113&out=json",
cache: false,
dataType: "json",
success: function(data) {
$.each(data.issue.page, function(i,item) {
imagesJSON[i] = item["@attributes"];
});
alert(imagesJSON.length);
},
error: function (request, status, error) { alert(status + ", " + error); }
});
Make sure you have cache: false
.
UPDATE:
It appears to be a configuration issue at the host with the request url that the OP actually uses. Going to the url directly with IE web browser results in an abort from the host. You can't do much than to report the issue to the host, like an email to the webmaster of the host.
I had the same error on a page, and I added these lines :
<!--[if lte IE 9]>
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.0/jquery.xdomainrequest.min.js'></script>
<![endif]-->
and it finaly works for me ;) no more error for IE9
This post helps me jQuery Call to WebService returns "No Transport" error
error: function(x) { }
block and then catch the error and look atx.responseText
to see if an error is returned. – csharpnumpty Commented Apr 25, 2012 at 12:10