this is my first question to the stack.
jQuery.ajax type: Post to an ashx file not being initiated in IE. works fine in FF, Chrome, and Safari
Code below:
$.ajax({
type: "Post",
url: "http://[ ... ]loguserdata.ashx?" + dataString,
data: "",
cache: "false",
contentType: "text/plain",
success: function(msg){
//alert( "Data Saved: " + msg );
}
});
by works fine in FF, etc. I mean the ashx file is called and info is logged.
I can see the ajax call in fiddler, firebug and chrome’s equivalent.
but there doesn’t seem to be jackchit happening in IE9 or in IE compatibility mode.
I can get several versions of the code above to work in the other browsers. Including a $('#result').load( ...
but NOTHING works in IE
btw, works fine locally in IE.
oh, and I don’t give a diddly poo about any return value.
and it’s not a cache issue. I have a date=getTime() tacked onto the end of the querystring.
querystring (dataString) looks something like fname=john&lname=doedy
EDIT: I have solved this issue. I will post a thorough answer tomorrow when I have time.
Long story truncated:
You can’t do a XMLHttpRequest crossdomain. Use jQuery’s getJSON method with the querystring parameter &callback=? added to the url. This I believe converts the datatype to JSONP.
Here are a few links that helped me solve this.
XMLHttpRequest cannot load an URL with jQuery
http://api.jquery.com/jQuery.getJSON/ see excerpt below
http://api.jquery.com/jQuery.ajax/ see excerpt below