jQuery & easyui 123

Several consecutive ajax requests may result in empty data returned

 

    (1) The last correct data row may be returned each time, but the first two data are empty.

initPayerDg();
initHouseDg();
initContractDg ();

 

    (2) Change it to return and then call the next one, and it can return correctly every time.

function initPayerDg() {
	$('#payerListDg').datagrid({
		url : '/rest/payer/owners?pyrnum=' + PNO,
		onLoadSuccess:function(data){
			initHouseDg();
		}
	});
	//$('#payerListDg').datagrid("reload");
}

function initHouseDg() {
	$('#houseListDg').datagrid({
		url : '/rest/payer/houses?pyrnum=' + PNO,
		onLoadSuccess:function(data){
			if(data.length>0){
				$('#houseListDg').datagrid("selectRow",'0');
			}
			initContractDg ();
		}
	});
	// $('#houseListDg').datagrid("reload");
	
}

function initContractDg () {
	$('#contractListDg').datagrid({
		url : '/rest/payer/contracts?pyrnum=' + PNO
	});
	// $('#contractListDg').datagrid("reload");
}

  

 

 (3) The dataGrid has set the url, and the data will be automatically loaded once, and reload is not required.

 (4) Solve the problem of requesting the json data of the url twice when the easyui datagrid control page is loaded, because the url is set in js as above, it will be automatically called once. So you need to comment out <table id="payerListDg" <%--class="easyui-datagrid"--%>.../>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326563206&siteId=291194637