1. Traditional way
<span style="font-size:18px;">$(function () { var url = "../Source/Query/jhDataQry.ashx?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>