2013-06-08 2 views
0

У меня есть 2 jQuery Ajax Получить методы на моей странице. Как мне запустить функцию внутри моего метода ajaxStart только тогда, когда Ajax Get внутри ShowDeviceDetails запущен, а не Ajax Get внутри моего метода BuildDeviceGrid?Как сделать jQuery ajaxStart различимым

Первый:

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 }); 


} 

ответ

0

Я надеюсь, что я понял ваш вопрос прямо (не стесняйтесь уточнить), но вы можете легко вызвать другую функцию, как показано ниже :

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

       $("#ajxWaiting").show() 

      } 
     } 

    }); 

, а затем положить function(){$("#ajxWaiting").show()} внутри BuildDeviceGrid.

Смежные вопросы