Ajax email contact form without refreshing page in html

I got some email regarding this problem "How to send Ajax email contact form without refreshing page in html" , so I decided to share very simple tutorial to solve such problem with simple concept. If you don't want to read article then no worry you can download source code from bottom of article. But if you want to know all the process behind it then, Let's start-

submit email form without refreshing page in html

Step 1- Create 2 files one is in .html and second one is .php (html file for contact form and PHP file for email route setup).

Simple Form Code :

Step 2 - Open your html & mail.php and paste above form code or you can use your own contact form input area and html.

Step 3 - Create id for each input as you see in my form field, there are three input, name , email & message. (id because we call ajax from such ids)

Step 4- Check below jquery code, give small attention you can know everything easily.

Clearing Doubt Of Above Ajax Html Email Contact Form:

First we click on button and it would be "#submitBtn" and after that I'm getting value of every id of form.

After that I'm creating data string and sending via ajax to mail.php.

After success retrieving data in id "#feedback" (Here response from mail.php will be displayed).

You should remember :

Ajax script should in head and you need Live server to run php server self mail function.

Everything done. Let me know if anything else or you have any query.

Download Source Code

Himanshu is a young engineer living in India. Currently working at Cognizant as a Senior Engineer. He is an ethical hacker & blogger too, doing lots of crazy stuff... If you seem interesting, go through his portfolio: www.himstar.info : "Open Source. Millions of open minds can't be wrong!

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Site Footer

Sliding Sidebar

We are India’s largest Startup Community

We are team of ' Delhi Startups ' , most active startup community with strict spam policy.
We are making !deas happen..for future, business and jobs without charging anything, with connecting entrepreneurs.. It's a reason to trust on us.
Come and join or subscribe, we will defiantly give a reason to like us.

Our Facebook Page