0

私のページには 2 つの jQuery Ajax Get メソッドがあります。BuildDeviceGrid メソッド内の Ajax Get ではなく、ShowDeviceDetails 内の Ajax Get が開始された場合にのみ、ajaxStart メソッド内で関数を起動するにはどうすればよいですか?

最初の1つ:

function ShowDeviceDetails(DeviceId) {

    $.ajax({
        type: "GET",
        url: 'GetCompDesktopDetails?id=' + DeviceId,
        dataType: "html",
        success: OnSuccess,
        onStart: function(){$("#ajxWaiting").show()},
        statusCode: {
            200: function () {

                $("#ajxWaiting").show()

            }
        }

    });
}

二つ目:

function BuildDeviceGrid() {
    var searchText = "test";
    $("#list").jqGrid({
        url: '/Computer/GetComputerGridData?searchterm=' + searchText + '',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Id', 'IPAddress', 'HostName'],
        colModel: [
            { name: 'DeviceId', index: 'DeviceId', width: "30%", align: 'left',  searchoptions:{sopt:['cn']}},
            { name: 'IPAddress', index: 'IPAddress', width: "100%", align: 'left', searchoptions: { sopt: ['cn'] } },
            { name: 'HostName', index: 'HostName', width: "120%", align: 'left', searchoptions: { sopt: ['cn'] }}],
        pager: $('#pager'),
        rowNum: 1000,
        rowList: [5, 10, 20, 50],
        sortname: 'DeviceId',
        sortorder: "desc",
        loadonce:true,
        viewrecords: true,
        imgpath: '/Content/jQueryTesting/jquery-ui-1.10.3.custom/css/smoothness/images',
        caption: 'Computers',
        gridview:true,
        multiselect: false,
        navigator: true,
        height: 200,
        width: 600,
        onSelectRow: function (rowId) {
            //alert(rowId)
            var rowData = $('#list').jqGrid('getRowData', rowId)               
            SelectedDeviceId = (rowData['DeviceId'])                
            ShowDeviceDetails(SelectedDeviceId)
        }
    });
    //jQuery("#list").jqGrid('navGrid', '#pager', { add: false, edit: false, del: false }, (filterToolbar, { searchOperators: true }));
    jQuery("#list").jqGrid('filterToolbar', { searchOperators: true });


}
4

1 に答える 1

0

私はあなたの質問を正しく理解したことを願っています(明確にしてください)が、以下のように別の関数を簡単に呼び出すことができます:

$.ajax({
        type: "GET",
        url: 'GetCompDesktopDetails?id=' + DeviceId,
        dataType: "html",
        success: OnSuccess,
        onStart: BuildDeviceGrid,
        statusCode: {
            200: function () {

                $("#ajxWaiting").show()

            }
        }

    });

そしてfunction(){$("#ajxWaiting").show()}中に入れますBuildDeviceGrid

于 2013-06-08T23:55:16.587 に答える