Can we submit a form by ajax using Jquery?

Submitted by: Murtaza
Please follow below code to submit a form by ajax using jquery

$('#formid).submit(function() {
$.ajax({
type: "POST",
url: "back.php",
data: "name=php&location=india",
success: function(msg) {
alert( "Data Saved: " + msg );
}
});
}

Where formid is the form ID."POST" is the method by which you want to send data.You can also use "GET" method."back.php" is the php file which you want to call."name=php&location=india" This is values of control. success: function(msg){ alert ("Data Saved: " + msg); } This is a success function, This will execute after success of you post.Often in Ajax back.php does not refresh because this is cached by browser. To avoid this issue add [cache: false,] in above code.Loads data synchronously. Blocks the browser while the requests is active. It is better to block user interaction by other means when synchronization is necessary.

To avoid this issue add [async: false,] in above code.
Submitted by: Murtaza

Read Online Creative UI/UX Designers Job Interview Questions And Answers