开发者

jQuery and IE8: Form action and submit problem

开发者 https://www.devze.com 2022-12-17 15:30 出处:网络
I have some code that isn\'t doing what I want it to in IE8. When you hit the \"preview\" submit button, a bit of Javascript jumps in and changes the form\'s action to franchisepreview.php. This sets

I have some code that isn't doing what I want it to in IE8. When you hit the "preview" submit button, a bit of Javascript jumps in and changes the form's action to franchisepreview.php. This sets a session variable so when you go back to the form you won't loose anything. Hitting "Update" or "Insert" goes straight to a query that inserts a franchise.

In IE8 the Javascript isn't jumping in. It submits the form without ever changing the action.

The bit of jQuery I'm using:

The bind:

jQuery("#preview").bind("click", changeForm);

The function changeForm:

function changeForm(event)
{
    alert("Before: "+ jQuery("#franchiseform").attr("action"));
    jQuery("#franchiseform").attr("action", "franchisepreview.php");
    alert("After: "+ jQuery("#franchiseform").attr("action"));
    jQuery("#franchiseform").submit(开发者_运维技巧);
}  


Maybe try chaining to make sure the attribute is set before the form is submitted:

jQuery("#franchiseform").attr("action", "franchisepreview.php").submit();

Doesn't look like .attr() accepts a callback.

0

精彩评论

暂无评论...
验证码 换一张
取 消