User clicks on a menu, and using the following code, the menu $.load()
s it's linked content:
$(function() {
$('#menu a').click(function() {
$('#content').load(this.href);
return false;
});
});
OK, now the form's loaded. There is still a problem. When the forms is submitted, the result shouldn't bring us to the real action
address. So I'm using the following code:
$('#content').on('submit', function() { // catch the form's submit event
alert('begin');
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(response) { // on success..
alert('aaaa');
$('#content').html(response); // update the DIV
}
});
return false; // cancel original event to prevent form submitting
});
Unfortunately on
is not called and alert('begin');
doesn't work!
Thanks to jquery submit form and then show results in an existing div