I would like to insert data in mysql db through ajax. I have follow the apporach in the list,however, it doesn’t mention what i should do in the php part. In this example it only show
var queryString = $.param(formData);
// jqForm is a jQuery object encapsulating the form element. To access the
// DOM element for the form do this:
// var formElement = jqForm[0];
alert('About to submit: \n\n' + queryString);
and a string of the input value is obtained, how can i retrieve them in my mysql page?thankyou
Also, i notice that when i combine this with jquery form validation plugin, the form will submit before check , i know there is an option to halt the submit, but is there any code to let the ajax know the code is vaildated?
thank you !
You can use an if statement to validate the data from your form, then if it returns valid data, it can run the the ajax request with the query string. As for the PHP, depending on your method of sending the variables, you can either use:
You should also make sure that you are validating and escaping all of your variables in your php script before you insert them into your database to prevent injection.