So I'm new to javascript and I'm actively trying to learn it for work. However, the project I've been working on has come to a screeching halt because my program never reaches the 200 ready state. can anyone help?
Code:
<html>
<head>
<script>
function queryDB(cpid, radar, year, month, day)
{
if (day=="")
{
document.getElementById("result").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
alert(xmlhttp.readyState + " " + xmlhttp.status);
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
var url="query.php?cpid="+cpid+"&radar="+radar+"&year="+year+"&month="+month+"&day="+day;
xmlhttp.open("GET",url, true);
xmlhttp.send();
}
</script>
</head>
You're using a relative URL in your AJAX request. Based on your code, you need to be sure that 'query.php' resides in the same directory as the HTML page. If it does, test the query.php script itself by entering the complete URL in your browser to make sure it's responding properly.
i just ran a test where i had an alert set to show where it is in the ready state. it would reach 4/200, display it but then tit would return to 1/0 and the results would be gone
i just ran a test where i had an alert set to show where it is in the ready state. it would reach 4/200, display it but then tit would return to 1/0 and the results would be gone
What happens after that, does it keep making requests?
Can you show how the function is being called?
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
it produces 5 alerts:
1 0
2 200
3 200
4 200
1 0
after i click ok on the 4 200, i see the results appear on the page, then after i click ok on the 1 0 alert, the results are gone.
Bookmarks