Reputation: 6047
I have something to the effect of :
<a href="#" >click me</a>
And:
$(document).ready(function() {
$('a').click(function() {
$('<form action="/" method="post"></form>').submit();
return false;
}
}
The expected result is that clicking the anchor will submit the form and redirect the page. This works in Chrome and Firefox. In Internet Explorer 9, the browser just follows the link to #. Any solutions?
Upvotes: 1
Views: 925
Reputation: 408
Try this
$('a').click(function() {
var form = '<form action="/" method="post"></form>';
$('body').append(form);
$('form:last').submit();
} );
Upvotes: 3
Reputation: 95048
I would try appending the form to the body first. However, why do you need a form at all?
$(document).ready(function() {
$('a').click(function() {
$.post("/");
return false;
}
});
Upvotes: 0