jqGrid display default “loading” message when updating a table / on custom update

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 15:47:53

If I correct understand what you will, I can recommend you to use jQuery blockUI plugin (http://malsup.com/jquery/block/). Then you don’t need more to use "async : false" parameter of $.ajax function and do something like following:

var WaitMsg = function () {
    jQuery('#main').block({ message: '<h1>Die Daten werden vom Server geladen...</h1>' });
};
var StopWaiting = function () {
    jQuery('#main').unblock();
};

WaitMsg();
$.ajax({url : '/DisplayObAnalysisResults.action?getCustomAnalysisResults',
        data: jQuery.param({portfolioCategory: $('#portfolioCategory').val(),
                            subPortfolioCategory: $('#subPortfolioCategory').val(),
                            subportfolio: $('#subportfolio').val()}),
        complete: function (data, status) {
            if (status === "success" || status === "notmodified") {
                var ob_GridJsonContents = jQuery.parseJSON(data.responseText);
             ...
            }
            StopWaiting();
        },
        error: function (xhr, st, err) {
            // display error information
            StopWaiting();
        }
});

I recommend you don’t build parameters with the way like

"portfolioCategory="+ $('#portfolioCategory').val() +"&subPortfolioCategory="+ $('#subPortfolioCategory').val() + "&subportfolio=" + $('#subportfolio').val()

because you can receive encoding problems, if data returned by .val() have some special characters. You could use JavaScript function encodeURIComponent in such cases (like encodeURIComponent($('#portfolioCategory').val())) or jQuery.param function if you construct a string like p1=val1&p2=val2&...pN=valN.

Best regards
Oleg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!