I am sending a request to ajax/matchreport.php along with the attribute ?minute=x when the request comes back i want it to add 1 to the minute and then resend so:
ajax/matchreport.php?minute=0
ajax/matchreport.php?minute=1
Using this code the first time the request does it correct then it enters NaN instead of a number after minutes
ajax/matchreport.php?minute=0
ajax/matchreport.php?minute=NaN
Any ideas??
Code:
<script language="javascript" type="text/javascript">
<!--
function MatchController(match_id) {
this.match_id = match_id;
this.minute = Number(0);
}
MatchController.setMinute = function(minute) {
minute = Number(minute);
this.minute = (minute - 1) + 1;
MatchController.setGame();
}
MatchController.setGame = function() {
// Display Loading Image
document.getElementById('loading').innerHTML="<img src='images/css/ajax-loader.gif' class='noimg' /> Playing Match";
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your Browser Does Not Support Ajax/Javascript!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
// Hide Loading Image Then Re Send The Function If Minutes Under 90
document.getElementById('loading').innerHTML="";
MatchController.setMinute(this.minute);
}
}
var queryString = "?minute=" + Number(this.minute);
ajaxRequest.open("GET", "ajax/matchreport.php" + queryString, true);
ajaxRequest.send(null);
}
</script>
Last edited by evans123; 12-27-2008 at 03:09 PM..
|