- This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
Viewing 9 posts - 1 through 9 (of 9 total)
- The forum ‘Other’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello!
I want to use Chris’s contact form in my website but I want it to not refresh the page when I click on submitt button.
Is there anyway to make it ajax to work this way?
If yes how?
Thanks in advance!
Alireza.M
I don’t know what you mean by Chris’ contact form but sure you can use JavaScript to intercept the form submit and then submit it using AJAX instead, prevent it’s default behavior and wait for the response to update the page.
With jQuery it would be something like:
$(‘#form_id’).submit(function() {
// prevent default
// make AJAX call, sending form values
// update page on complete
});
Pretty sure there is more to it than that. Here is how I put it all together. It was not easy. http://www.websitecodetutorials.com/code/jquery-plugins/jquery-ajaxsubmit.php
Pretty sure there isn’t: http://crocodillon.com/temp/ajaxform.html
@CrocoDillon nice. But you cant use php validation with that right?
Sure you can, the php file I have is really simple (for demo only) but you can do everything with the POST data you want.
echo ‘Hello there, ‘.htmlspecialchars($_POST).’!’;
else
echo ‘Hello there, Mr. Smith!’;
Don’t mind me sending html back though, XML or JSON would probably be better (if you want to give feedback on validation errors).
cool – cool. I stand corrected. :)
:)
Thank you CorocoDillon!
It worked as it was in my mind.
Thanks again!