我的页面上有 2 个 jQuery Ajax Get 方法。仅当 ShowDeviceDetails 中的 Ajax Get 启动而不是 BuildDeviceGrid 方法中的 Ajax Get 时,如何在 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 });
}