Menu icon Foundation
Contact form same page refresh issue

Hi guys.

I am new to using Foundation, but have managed to put together a working contact form for the site I am working on.

However, when the form is submitted the div that contains the success or error message to the user for some reason also contains my default.html layout.

This results in a bunch of un-rendered html code on the page before the success or error message.

Any ideas as to how the form can be submitted without my default.html layout loading within the div?

Any help would be appreciated.

contact formPHPAJAX

Hi guys.

I am new to using Foundation, but have managed to put together a working contact form for the site I am working on.

However, when the form is submitted the div that contains the success or error message to the user for some reason also contains my default.html layout.

This results in a bunch of un-rendered html code on the page before the success or error message.

Any ideas as to how the form can be submitted without my default.html layout loading within the div?

Any help would be appreciated.

Vladimir over 3 years ago

@Tom Stockton any live example? It is hard to find a problem this way :)

Tom Stockton over 3 years ago

Might be tricky because I am working locally and using PHP.

I used this tutorial to create the form though:
http://blog.teamtreehouse.com/create-ajax-contact-form

Vladimir over 3 years ago

@Tom Stockton it sounds like you are returning that page as a result instead of success/error data... But without live example I can't help you.

Tom Stockton over 3 years ago

@Vladimir Hm. Would sharing the code and a screenshot of the result I am getting help?

Vladimir over 3 years ago

@Tom Stockton I was looking at the script on that page you posted and it is pretty easy one. I don't know what you altered on your side and that is why I wanted to see live example (also that way I can see what is mailer returning to page and in what form...)
Also, are you absolutely sure that returned html is from default.html page? To many variables here to give you exact answer :)

Tom Stockton over 3 years ago

@Vladimir I haven't actually altered anything with the script and mailer.php. I wanted to make sure it worked before making any adjustments :).

Yeah it's definitely the default.html being returned within the project.

It has left me scratching my head in confusion to be honest with you!

Vladimir over 3 years ago

@Tom Stockton one question, does this script sends email in first place?If it does then this has to do something with your server configuration since this is very simple script (and to tell you honestly, using mail() function on live server will bring you tons of headaches ;) trust me, I've been there couple of times and I can explain where are the problems if you continue to use mail() ).

Tom Stockton over 3 years ago

@Vladimir Yeah the email is being sent with no problems. Its just the refresh issue when the email has been sent causing issues.

I tested the script locally with MAMP so haven't had to look into server configuration much.

Ahh, thats making me want to look for another solution entirely.