Forum Moderators: open
function objetoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function OnSubmitBooking()
{
if(document.Booking.emailtrue.value != document.Booking.repeat_email.value)
{
document.getElementById('repeat_emailbox').style.display = "block";
divresult = document.getElementById('repeat_emailbox');
divresult.className = 'validation'
divresult.innerHTML = 'Emails are not equal';
document.Booking.repeat_email.focus();
return false;
}
var info = {
names : ['namebox' , 'Please fill in name' ],
passport : ['passportbox' , 'Please fill in your identification' ],
emailtrue : ['emailtruebox' , 'Please fill in email' ],
repeat_email: ['repeat_emailbox', 'Please repeat email' ],
telmobile : ['telmobilebox' , 'Please fill in mobile to bring on holiday' ]
}
for( key in info ) {
if(document.Booking[key].value == '')
{
divresult = document.getElementById(info[key][0])
divresult.className = 'validation'
divresult.innerHTML = info[key][1];
document.Booking[key].focus();
return false;
}
}
divresult = document.getElementById('resultbooking');
var enviar = document.Booking.enviar.value,
question = document.Booking.question.value,
answer = document.Booking.answer.value,
test = document.Booking.test.value;
var ajaxcaptcha = objetoAjax();
ajaxcaptcha.open("POST", "captchaajax.php", true);
ajaxcaptcha.onreadystatechange = function () {
if (ajaxcaptcha.readyState==1 || ajaxcaptcha.readyState==2 || ajaxcaptcha.readyState==3)
{
divresult.className = 'validationok'
divresult.innerHTML = 'Please wait...';
}
if (ajaxcaptcha.readyState == 4) {
if (ajaxcaptcha.responseText === "Loading, please wait") {
var enviar = document.createElement('input');
enviar.type = 'hidden';
enviar.name = 'enviar';
enviar.value = true;
document.Booking.appendChild(enviar);
document.Booking.submit();
} else {
divresult.className = 'validation'
divresult.innerHTML = ajaxcaptcha.responseText
}
}
}
ajaxcaptcha.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajaxcaptcha.send("test=" + test + "&enviar=" + enviar + "&answer=" + answer +
"&question=" + question + "");
return false;
}
I'd start by opening Chrome's dev tools (press F12), view the Sources tab, and enter a breakpoint at the top of your function, then when that code executes, step through it to see what it's doing.