Peter Peter - 1 month ago 10
jQuery Question

IE not triggering jQuery Ajax success

I'm working on a script to load some images async using jQuery.

Here is a code snippet of the function that loads the images -

try{
for(img in imgsArray){
$.ajax({
async: false,
type: "get",
url:imgsArray[img],
success:function(imgFile){
alert("success");
//do something useful
},
error:function(XMLHttpRequest,status,error){
//do nothing
}
});//ajax
}
}
catch(e){
//oops
}


I have tested this in Firefox, Webkit (Safari,Chrome) and it works.

The images are in a folder on the server and I'm using jQuery 1.3.

any ideas?

Answer

A simple fix of this problem is to provide the jQuery setting dataType : 'text' or dataType : 'xml' or dataType : 'json' or any other available response type.

I had same problem, but it's working fine after specifying the dataType setting in the .ajax call.

IE is really not an intelligent browser, it doesn't assume the default value string.

Try it... good luck.

Comments