Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2017-12-01 19:35:00

zenman
Member
Registered: 2017-08-28
Posts: 16
Website

Re: Integrate thickbox with Zem Contact Form using Ajax

etc wrote #307204:

Yes, but without quotes:

http.open("POST", $(this).attr('action'), true);...

finally found some time for testing. tried this method but still the page is reloaded. here is the script

document.getElementById('zcr592d92e49daf16a20e10e15e1216817c').onsubmit = function(){
	var field_name =  document.getElementById("InputFullName").value;
	var field_phone =  document.getElementById("InputPhone").value;
	if (field_name.length!=0 && field_phone.length!=0) {
		var http = new XMLHttpRequest();
			  http.open("POST", $(this).attr('action'), true);
			  http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			  http.send("InputFullName=" + this.InputFullName.value + "&InputPhone=" + this.InputPhone.value + "&InputEmail=" + this.InputEmail.value + "&InputFromZip=" + this.InputFromZip.value + "&InputToZip=" + this.InputToZip.value + "&InputDateofMove=" + this.InputDateofMove.value + "&InputMoveSize=" + this.InputMoveSize.value + "&InputOtherRemarks=" + this.InputOtherRemarks.value);
			  http.onreadystatechange = function() {
				if (http.readyState == 4 && http.status == 200) {
				  $('.alert-success').show().delay(5000).fadeOut(1000);
				  $('.alert-danger').hide();
				  $('#zcr592d92e49daf16a20e10e15e1216817c').trigger( 'reset' );
				}
			  }
			  http.onerror = function() {				
			  }
			  return false;
	}
	else {
		$('.alert-danger').show();
		$('.alert-success').hide();
		return false;
	}
}

By the way, I replaced txp:zem_contact_submit with

<button type="submit" class="btn btn-success" >Send Quote</button>

and it works!

Offline

Board footer

Powered by FluxBB