The reason analysis and solution of Easyui loading two times URL in JQuery _jquery

Source: Internet
Author: User

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: [Ten, A, 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. Reason Analysis and solution

The HTML code uses class to declare the DataGrid, which causes Easyui parsing class code to parse the DataGrid in the class declaration first, so that the component requests a URL, and then calls the JS initialization code to request a URL at a time. This results in repeated loading by simply declaring the Easyui component in an initialization way to avoid duplicate commit requests, that is, to delete the class declaration (class= "Easyui-datagrid") in HTML, and 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: [A, M, 50,100,5000],idfield: ' Chjid ', sortname: ' chjbh ' ' 
rownumbers= ' true ' singleselect= ' True "Url=". /source/jichu/chjdoc.ashx "> 
<thead> 
<tr> 
</tr> 
</thead> 
</ Table></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.