Reputation: 572
Is it possible to remain the values in textbox after submited the form and remain the same page using jQuery ajax?
I'm sorry that I don't have examples to demonstrate.
Thanks in advance.
Upvotes: 1
Views: 4935
Reputation: 2698
In your submit callback you could preventDefault
the submit event. You would then just handling it by yourself with ajax.
$('#yourform').submit(function(event) {
event.preventDefault(); // disable default submit behaviour of the browser
$.post($(this).attr('action'), $(this).serialize()); // handle the post via ajax
});
<form id="yourform" action="script.php">
<input type="text" name="field">
<input type="submit" value"Go">
</form>
Upvotes: 1
Reputation: 595
You can submit your page using jquery/ajax look at it- suppose html code is-
<form id="target" action="destination.html">
<input type="text" value="Hello there" />
<input type="submit" value="Go" />
</form>
now ajax code will be-
$('#target').submit(function() {
alert('Handler for .submit() called.');
return false;
});
Upvotes: 0