Hi all, trying to make a page which will recursively call a function until a limit has been reached and then to stop. It uses an ajax query to call an external script (which just echo's "done" for now) howver with neither onSuccess or onFailure triggering i'm finding it hard to find the problem.
Here is the javascript for it. In the header for the webpage there is a script to an ajax.js document which contains the request data. I know the ajax.js works as I've used it on another website
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>National Lettings Inventories</title>
<link type="text/css" href="/inv/default.css" rel="stylesheet" />
<script type="text/javascript" src="/inv/includes/swfobject.js"></script>
<script type="text/javascript" src="/inv/includes/ajax.js"></script>
<script type="text/javascript">
swfobject.registerObject("myFlashContent", "9.0.0");
</script>
</head>
<body onload="start()">
<div id="topBar">
<div class="logo">
</div>
</div>
<div id="Body">
<script type="text/javascript">
<!--
var rooms = 1;
var items = 0;
var ccode = "9999/1";
var x = 0;
function echo(string,start){
var ajaxDisplay = document.getElementById('ajaxDiv');
if(start)
{ajaxDisplay.innerHTML = string;}
else
{ajaxDisplay.innerHTML = ajaxDisplay.innerHTML + string;}
}
function locations()
{
echo("Uploading location "+x+" of " + rooms,true);
Ajax.Request("Perform/location.php",
{
method:'get',
parameters: {ccode: ccode, x: x},
onSuccess: function(reply)
{alert("worked");
if(x<rooms)
{
x++;
locations();
}
else
{
x=0;
echo("Done",true);
}
},
onFailure: function()
{alert("not worked");
echo("not done");
}
});
alert("boo");
}
function start()
{locations();}
//-->
</script>
Uploading
<div id='ajaxDiv'>
</div>
</div>
<div class="link" id="bottom">
<a href="index.php" ><img src="/inv/images/back.gif" class="link" alt="BACK"/></a>
</div>
<div id="bottomBar">
<p>Copyright © 2010 National Lettings Inventories</p>
</div>
</body>
</html>
Opera Error Console
JavaScript - http://localhost/inv/Upload/upload.php
Event thread: load
Error:
name: TypeError
message: Statement on line 89: Cannot convert undefined or null to Object
stacktrace: n/a; see opera:config#UserPrefs|Exceptions Have Stacktrace
Any help or advice will be most appreciated.
EDIT: Added the whole page source code, theres no line 89 here though