Here is what I got:
<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; }
This works well, but my problem is that it will not present the form. I tried both $('form').submit()
and $('#myform').submit()
inside the data == '1'
statement. I tried alert(1)
inside this if statement, and it displayed in order, I only need to submit the form, why does this not work?
Update:
The console says:
Uncaught TypeError: Property 'submit' of object
Karem source share