Ajax Request not working. onSuccess and onFailure not triggering

Posted by Kye on Stack Overflow See other posts from Stack Overflow or by Kye
Published on 2010-03-24T11:02:02Z Indexed on 2010/03/24 11:23 UTC
Read the original article Hit count: 239

Filed under:
|

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

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");
} 

Any help or advice will be most appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX