这就是我得到的:
<form method="post" id="myform" class="myform">
<input type="submit" onclick="return claim();" name="submit" class="onsubmit" value="" />
</form>
function claim() {
var c = confirm('You sure?');
if (!c) {
return false;
}
var password = prompt("Please mention pw","");
if (password != null && password != "") {
$.post(
"/claim/",
{ partner_pwd: password },
function(data) {
if (data == '1') {
$('form').submit(function() {
alert('Handler for .submit() called.');
});
}
});
}
return false;
}
这很好用,但我的问题是它不会提交表单。我在声明中$('form').submit()
都试过了。我在这个if语句里面试过了,它显示得很好,我只需要让它提交表单,为什么这不起作用?$('#myform').submit()
data == '1'
alert(1)
更新:
控制台说:
Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function jquery.min.js:3 f.event.trigger