In this ASP.NET MVC 3 view, I need to control form submission completely via JavaScript (I use jQuery). Specifically, my form submission logic contacts the server via SignalR, which is a Comet framework (an improvement on Ajax, basically).
How can I install a JavaScript handler for any type of submission of forms in the view (e.g., via clicking the submit button or pressing Enter in a field)? The handler also needs to completely disable 开发者_Go百科form submission while the server is processing.
Keep in mind that I'm doing unobtrusive client-side validation of forms in the view as well.
You could use the jQuery form plugin. Or do it manually by adding a global script to all pages:
$(function() {
    $('form').submit(function() {
        if ($(this).valid()) {
            // client validation passed => send it with AJAX
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize()
            });
        }
        return false;
    });
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论