Creative UI/UX Designers Question:
Download Questions PDF

Can we submit a form by ajax using Jquery?

Answer:

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.

Download Creative User Interface UX Interview Questions And Answers PDF

Previous QuestionNext Question
Can you combine Jquery combined with other libraries?Explain what is jQuery UI?