I have a form that has two AJAX calls to our DB server. The first works fine - but after that, the second triggers the error:
“Uncaught ReferenceError: AJAX is not defined” (and gives the line number of the second AJAX call)
My test code is here :
var queryNetIDVotes = "SELECT audiencevoters.netID, voting.team_name, voting.rating FROM voting INNER JOIN audiencevoters ON voting.aud_id=audiencevoters.aud_id ORDER BY audiencevoters.netID";
req2 = Ajax("http:/XXXXXXXX/XXXXX/ajax-connection.php", "POST", "host=XXXXXXX&user=XXXXXX&pass=" + pw + "&database=XXXXXXX&query=" + queryNetIDVotes);
if (req2.status == 200) { //everything worked. :P
allNetIDTeamRatings = JSON.parse(req2.responseText);
console.log("The all data parsed are: allNetIDTeamRatings");
} else
console.log("Error Network first call Will Robinson");
// second DB call
addQuery = "INSERT INTO audiencevoters VALUES('`' + netID + '`,`' + firstname + '`,`' + lastname + '`')";
req3 = AJAX("XXXXXXXX/XXXX/ajax-connection.php", "POST", "host=XXXXXXXXX&user=clc90595&pass=" + pw + "&database=XXXXXXXX&query=" + addQuery);
// return message to user
if (req3.status == 200) {
second = JSON.parse(req3.responseText);
console.log(second);
} else
NSB.MsgBox("Error network second call");
This is run on response to a button click event.
My question: can you run more than one AJAX call in a form? Thanks -