开发者

jquery validate and jqgrid on same page

I am using jqgrid and jquery validate plugin on same page but when I include validate plugin jqgrid is unable to load json data. When I remove the validate plugi开发者_JS百科n it starts working perfectly. I get the follwing error.

Invalid label Line: 0, Column: 1 Source Code: {"page":"1"


I could reproduce your problem with jQuery Validate 1.7. I could suggest very easy workaround: to comment the following lines of jQuery.Validate.js:

// ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 
;(function($) {
    var ajax = $.ajax;
    var pendingRequests = {};
    $.ajax = function(settings) {
        // create settings for compatibility with ajaxSetup
        settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
        var port = settings.port;
        if (settings.mode == "abort") {
            if ( pendingRequests[port] ) {
                pendingRequests[port].abort();
            }
            return (pendingRequests[port] = ajax.apply(this, arguments));
        }
        return ajax.apply(this, arguments);
    };
})(jQuery);

If you use the last version 1.8 of jQuery.Validate (you can download it here) no problem seems exist.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜