My attempt to use Ajax to interact with a servlet seems to be causing some issues. When I check the Net tab in firebug, I can see that the server is responding correctly. However, for some reason, my vulAan function is not being called by the Ajax request. To troubleshoot this, I added window.alert() functions to check if any function is being called. Surprisingly, only window.alert("request verstuurd") is getting triggered. Here is the code snippet:
window.onload = function() {
$("registreerform").observe("submit", controleer);
$$("input")[1].observe("blur", getVulAan);
$$("input")[2].observe("blur", getVulAan);
};
function getVulAan(event){
var post = $$("input")[1].value;
var huis = $$("input")[2].value;
if (post && huis) {
window.alert("request verstuurd");
event.stop();
new Ajax.Request (
"http://www.ntwpracticumnet.ou.nl:8080/registratie/PostcodeServlet",
{ method: "get",
parameters: {postcode: "1076CT", huisnr: "390"},
onSucces: vulAan,
onFailure: nietGelukt,
onExcepton: nietGelukt
}
);
}
}
function vulAan(ajax) {
window.alert("request geaccepteerd");
var jsWaarde = JSON.parse(ajax.responseText);
var plaats = jsWaarde.plaats;
var straat = jsWaarde.straat;
$$("input")[3].value = plaats;
$$("input")[4].value = straat;
}
function nietGelukt () {
window.alert("niet gelukt");
}
Can anyone pinpoint what might be causing this issue?