Jump to content

jQuery's AJAX form not working

Tock_Jacks

Your question seems a bit incomplete but I'll try to answer anyway. 

 

When you have an html form you don't necessarily have to use ajax. The form itself will submit the data when you click on the input type "sumbit". 

 

Where will this submit your form? Well, you added an action attribute that specifies that (action="include/register.php").

 

You also specified that the form should use a POST http request (method="POST" ). 

 

So when you click on submit, the browser will take your form and will try to perform a POST http request to "include/register.php".

You need some sort of server that listens for that post request and answer accordingly. 

It won't work if you only have that one html file. 

 

Adding jquery here probably does nothing, but it depends on what you're doing inside of "site_js.min.js".

Jquery script tag should probably come before your custom script as well. 

Link to comment
Share on other sites

Link to post
Share on other sites

Including jQuery just adds the ability to use jQuery's ajax methods, you will still need to write your own javascript with what you want it to do. If your custom code is in site_js.min.js, which we can't see, try putting the jquery script import above your site_js import, as they will load in order. That should at least be a step forward, even if everything doesn't magically work.

 

You'll then want to handle calling the php file in your ajax function, rather than attaching it to your form. The way you have it now, it will do a standard form submission, which might be fine for what you want, but if you want the registration to happen in the background rather than going to that php page, than you'll probably want to handle that via ajax.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×