1
如何跟蹤Ajax調用超時下面是一個簡單的AJAX功能Ajax請求超時
function process()
{
document.getElementById('message').innerHTML='Loading..';
var ajaxRequest; // The variable that makes Ajax possible
try
{
ajaxRequest = new XMLHttpRequest();
}
catch (e)
{
try
{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function()
{
if(ajaxRequest.readyState == 4)
{
var ajaxDisplay = document.getElementById('message');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var query;
query="process.php?action=delete";
ajaxRequest.open("POST", query, true);
ajaxRequest.send(null);
}