You shouldn't ever need to probe those individual states when using jQuery to make an Ajax connection. The function
jQuery.ajax() supports the "
error", "
success", and "
complete" parameters that let you fire your own custom code for any of the relevant Ajax outcomes. Something like:
Code:
$.ajax({
url: "myscript.php"
async: true,
error:function(ajaxrequest){
alert('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
},
success:function(content){
alert(content)
}
})
Native XMLHttpRequest states like 1 or 2 don't ever fire at all in some browsers, so they are not reliable anyway.