I have a jsp page as follows:
<script type="text/javascript" src="/mywebapp/js/jquery.js"></script>
<script type="text/javascript">
$( function() {
$('#testform').submit(function(){
alert('now starting submit');
return true;
});
$("#test1btn").click(function(){
$('#testform #submit').click();
});
$("#test2btn").click(function(){
$('#testform').submit();
});
});
</script>
<form id="testform" method="post" action="backend/search_test.do">
<input id="reqpagenr" name="reqpagenr" size="10">
<input type="button" id="test1btn" value="TestClick"/>
<input type="button" id="test2btn" value="TestSubmit"/>
<input id="submit" type="submit" value="Go">
</form>
When I manually click (i.e. using a mouse) the button "Go", the form is submitted after displaying the text "now starting submit"; when click the button "TestClick", the form is successful submitted but the text "now starting submit" doesn't come up; when click the button "TestSubmit", the text "now starting submit" appears, but the form is not submitted at all.
Contrary to my expections, the buttons "TestClick" and "TestSubmit" do not function as the button "Go" does when both are clicked. In my understanding, the three button clicks should do the same thing, that is, to submit the form after the text "now starting submit" appears. So my question is, why the results of the three button clicks is different?
I am using jquery 1.3.2