javascript - ajax inconsistent on Safari -
-edit-
i have tried add error handling failing function error: function(jqxhr, status, error)
jqxhr.responsetext
empty guess i'm still not handling errors properly.
-/edit-
i new ajax , have modify existing site these 2 existing ajax functions, both of working fine in chrome, ie , ff first works in safari. second 1 fails error handler (which guess wasn't set properly?) doesn't tell me much:
// works in each browser $.ajax({ cache: false, type: 'get', url: apibaseurl + 'getcountries', datatype: 'xml', success: parsecountries, error: function(){ $('.errormessage').append('<p>' + errormessage + '</p>'); } }); // not work in safari $.ajax({ cache: false, type: 'get', url: apibaseurl + 'getstandardtexts?page=login', datatype: 'xml', success: displayregisteredalert, error: function(jqxhr, status, error){ var err = eval("(" + jqxhr.responsetext + ")"); alert(err.message); } });
the real difference between them can see url in second contains , additional parameter, ?page=login
.
i got work. i'm not entirely sure why adding async:false
solved safari. not required other browsers.
$.ajax({ async: false, // required on safari cache: false, type: 'get', url: apibaseurl + 'getstandardtexts?page=login', datatype: 'xml', success: displayregisteredalert, error: function(jqxhr, status, error){ var err = eval("(" + jqxhr.responsetext + ")"); alert(err.message); } });
Comments
Post a Comment