Can someone show me a tutorial of using jquery to display successful form submission *without refreshing the page*. Something like that happens on gmail when a message is delivered and the yellow overlay that shows that you message was delivered and then fade outs. I want the message to be displayed depending on the result of the form submission.
+2
A:
first result on google,
submit a form without page refresh using jquery
second on google,
keywords used: jquery submit without refresh
Reigel
2010-09-23 09:18:33
A:
Ok ... something like this ... but I didn't try it ... so use it just like tutorial.. You can also use json
js:
function processForm() {
$.ajax( {
type: 'POST',
url: form_process.php,
data: 'user_name=' + encodeURIComponent(document.getElementById('user_name').value),
success: function(data) {
$('#message').html(data);
}
} );
}
html:
<form action="" method="post" onsubmit="processForm();return false;">
<input type='text' name='user_name' id='user_name' value='' />
<input type='submit' name='submit' value='submit'/>
</form>
<div id='message'></div>
form_process.php
$user_name = $_POST['user_name'];
if(do something){
echo "login success";
else{
echo "login unsuccessful";
}
jatt
2010-09-23 09:31:05