有人能告诉我为什么名为tellme的div只显示半秒钟的东西......或更少然后什么都不做?我已经尝试了所有方法,但却无法使代码生效。这很有趣,因为我在我的其他页面上有完全相同的代码并且它没有任何问题,所以有任何问题,我试图调用一个AJAX调用,它只是没有工作,它不会使div称为tellme任何东西,它&# 39;只是把它留空......
<script type="text/javascript">
function fireWorkerFixed(userid)
{
// Create our XMLHttpRequest object
var hr = new XMLHttpRequest();
// Create some variables we need to send to our PHP file
var url = "http://private.com/fire_worker.php";
var id = userid;
var vars = "userid="+id;
hr.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById('tellme').innerHTML = return_data;
}
}
// Send the data to PHP now... and wait for response to update the status div
hr.send(vars); // Actually execute the request
document.getElementById('tellme').innerHTML = "<div class='alert alert-info'>Please wait, Processing request...</div>";
}
</script>