Contact Form issue

3 replies · opened Jun 15, 2017

IicefieldJun 15, 2017

Checked thru prior forum questions and answers, but wasn't able to resolve.

Form can be filled, email is sent, but echo response is not showing in webpage.

Site is http://eventtruly.com (select 'Get Started' button to show popup form)

Have tried http://eventtruly.com/include/sendemail.php directly and am getting response to show directly in blank html page.

Would you be willing to look at my site and provide guidance on how to get php echo responses to appear on form after 'Send Message' is hit?

Thank you. - Tom

IicefieldJun 19, 2017

More info:

Modified ajaxSubmit in contactForm in functions.js. Added error and complete handler as follows:

$(form).ajaxSubmit({
		target: elementResult,
		dataType: 'json',
		//beforeSend: function(data) {
		//      alert(data.toSource());
		//},
		error: function(data) {
				alert("error");
		},
		complete: function() {
				alert("complete");
		},
		success: function( data ) {
				if( elementLoader == 'button' ) {
						defButton.html( defButtonText );
				} else {
						$(form).find('.form-process').fadeOut();
				}
				if( data.alert != 'error' && elementRedirect ){
						window.location.replace( elementRedirect );
						return true;
				}
				if( elementAlert == 'inline' ) {
						if( data.alert == 'error' ) {
								var alertType = 'alert-danger';
						} else {
								var alertType = 'alert-success';
						}

						elementResult.removeClass( 'alert-danger alert-success' ).addClass( 'alert ' + alertType ).html( data.message ).slideDown( 400 );
				} else {
						elementResult.attr( 'data-notify-type', data.alert ).attr( 'data-notify-msg', data.message ).html('');
						SEMICOLON.widget.notifications( elementResult );
				}
				if( $(form).find('.g-recaptcha').children('div').length > 0 ) { grecaptcha.reset(); }
				if( data.alert != 'error' ) { $(form).clearForm(); }
		}
});

I'm seeing error callback called, and then complete callback called, but not success callback. If I examine 'data' argument in error callback, I seeing what looks like a valid response from sendmail.php, including valid json response:

data
Object = $1
abort: function(a)
always: function()
complete: function()
done: function()
error: function()
fail: function()
getAllResponseHeaders: function()
getResponseHeader: function(a)
overrideMimeType: function(a)
pipe: function()
progress: function()
promise: function(a)
readyState: 4
responseText: "form posted{ \"alert\": \"success\", \"message\": \"We have **successfully** received your Message and will get Back to you as soo…"
setRequestHeader: function(a,b)
state: function()
status: 200
statusCode: function(a)
statusText: "OK"
success: function()
then: function()

Email is sent, response is received in error callback, but not getting success callback hit. Any guidance is appreciated any more at this point!

IicefieldJun 19, 2017

Even more info: According to https://stackoverflow.com/questions/32637677/jquery-ajax-call-returning-an-error-with-readystate-4-status-200-statustext-ok, this is caused by setting dataType to 'json', and returning an invalid json string.

I'm wondering if the responseText: "form posted{ ... }" show in the prior message is being treated as an invalid json string because of the "form posted" prefix.

Anybody seen anything like this? I've gripped the canvas code and do not find the string "form posted".

Guidance appreciated!

IicefieldJun 20, 2017

Got this resolved. Thank you.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard