Home  >  Article  >  Web Front-end  >  Reason analysis and solution for JQuery EasyUI loading the URL twice_jquery

Reason analysis and solution for JQuery EasyUI loading the URL twice_jquery

WBOY
WBOYOriginal
2016-05-16 16:39:241263browse

1. Traditional way

<span style="font-size:18px;">$(function () { 
var url = "../Source/Query/jhDataQry.ashx&#63;action=query"; 
$(dg).datagrid({ 
url: url, 
queryParams: { 
qsrq: qsrq, 
zzrq: zzrq 
} 
}); 
}) 

<table id="DataGrid" class="easyui-datagrid" fit="true" border="false" toolbar="#TBar" pagination="true" 
data-options="pageSize:20,pageList: [10, 20, 30, 40, 50,100,5000],idField:'chjid',sortName:'chjbh', queryParams: { 'action': 'query'}" 
rownumbers="true" singleSelect="true" url="../Source/JiChu/chjdoc.ashx"> 
<thead> 
<tr> 
</tr> 
</thead> 
</table></span>

2. Cause analysis and solutions

The datagrid is declared using class in the html code. When easyUI parses the class code, it first parses the datagrid in the class declaration, so that the component requests a URL; then it calls the js initialization code to request a URL. This leads to repeated loading. The solution is to use only one initialization method to declare the easyUI component to avoid repeated submission requests, that is, delete the class declaration (class="easyui-datagrid") in the html. The modified code is as follows:

<span style="font-size:18px;"><table id="DataGrid" fit="true" border="false" toolbar="#TBar" pagination="true" 
data-options="pageSize:20,pageList: [10, 20, 30, 40, 50,100,5000],idField:'chjid',sortName:'chjbh'" 
rownumbers="true" singleSelect="true" url="../Source/JiChu/chjdoc.ashx"> 
<thead> 
<tr> 
</tr> 
</thead> 
</table></span>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn