Ajax.BeginForm OnSuccess not executed after Submit
I am trying to use a jquery dialog to edit data in an WebGrid. Everythings works fine until the Form is submitted, instead of return to the current page that is open the brows开发者_如何学Cer goes to the url of the controller action. I am using an HTML.ActionLink in the WebGrid that adds jquery behavior to a button the WebGrid, and that works fine. It opens the View in a jquery dialog. The dialog defines two buttons: an update button and a cancel button. Clicking the cancel button does nothing. Clicking the update button takes the browser to the controller url for the edit action with the item id. I have the jquery.unobtrusive-ajax.js library defined and I added the UnobtrusiveJavaScriptEnabled key in the Web.config file, although I am not sure it's needed. Has anyone experienced this behavior, any help is appreicated!
I've experienced this problem in two situations:
- The event handler was not being
binded to the form's submit event, or it was not suppressing the default behavior (through
event.preventDefault();
orreturn false;
). - There was an error in the event handler, causing it to fall back to the default behavior.
Well this is how much I can try to help without any source.
When I had this issue I wasnt referencing the jquery-Ajax.unobtrusive library so ensure that's there too
From my entry at http://completedevelopment.blogspot.com/2011/02/unobstrusive-javascript-in-mvc-3-helps.html
1. Set the mentioned flag in the web.config: <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 2. Include a reference to the jQuery library ~/Scripts/jquery-1.4.4.js 3. Include a reference to the library that hooks this magic at ~/Scripts/jquery.unobtrusive-ajax.js
精彩评论