I recently struggled with jQuery and Ajax, trying to submit forms with them. I have a very simple form with a username and password field, as well as a submit button. It is assumed that the form should consist in the fact that after the form is submitted, the information will be sent by Ajax to the php file, which will then add the specified form values to the database. What I'm struggling with is how to get values from Ajax to php. Here is my code:
$('#form').submit(function(){
var username = $('#username').val();
var password = $('#password').val();
var dataString = 'uname=' + username + '&passw=' + password;
$.ajax({
type: "POST",
url:'check.php',
data: dataString,
success: function(data){
alert(data);
}
});
What eludes me, how can I get a dataString from this with php?
source
share