开发者

Safari Chrome form with no action not working

I'm building an app using Django and jQuery. For in some forms in the HTML I make AJAX c开发者_如何学Calls using only jQuery so I put the form with action="#" method="" and have.

When I press the submit button in FF it works fine, nothing gets reloaded and the ajax call is made. In Chrome and Safari, however, the page get's reloaded and re-requested from the server.

Any clues?


As much as possible, Webkit and Opera try to follow the HTML5 draft. Currently, the form submission section says that actions that start with HTTP(S), even if the action="#" or action="", will cause a navigate, which should cause a new page load when the new GET parameters are added. If you want to prevent the page from reloading, you'll have to add a submit handler that prevents the default action by returning false or saying e.preventDefault().


What happens if leave action and method out? You shouldn't need those anyways if you're submitting with an ajax call.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜