I'm making an ajax call with jQuery. The ajax call works fine in IE 7, but FireFox 3 always does a full page refresh when making this call. The ajax call is POSTing to an ASP.NET page method.
Is there a problem in jQuery or am I just missing some setting?
$.ajax({
async: false,
type: "POST",
url: "Default.aspx/DoSomething",
data: "{" + parms + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function(data) { succesfulPost(data); },
error: function(XMLHttpRequest, textStatus, errorThrown) {
errorPost(textStatus, errorThrown);
}
});
The call is being made from an html button onclick event. I tried the
return false;
in the method that is making this ajax call, but the full refresh in FireFox continues.
I've tried setting async = true, but that doesn't seem to work. FireFox just keeps going and doesn't wait for the backend to return a response. FireFox (in js) actually is generating an error in the ajax call. As you can see above, the error function is defined and this is triggered when I set async = true.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…