Solve the Problem of jquery easyui loading two URLs

Source: Internet
Author: User

1. Traditional Methods

 1 $ ( Function  (){  2               VaR Url = "../source/query/jhdataqry. ashx? Action = query" ;  3   $ (DG). DataGrid ({  4   URL: URL,  5  Queryparams :{  6   Qsrq: qsrq,  7   Zzrq: zzrq  8   }  9   });  10   })  11  12 <Table id = "DataGrid" Class = "easyui-DataGrid" Fit = "true" border = "false" toolbar = "# tbar" pagination = "true" 13 Data-Options = "pagesize: 20, pagelist: [10, 20, 30, 40, 50,100,500 0], idfield: 'chjid', sortname: 'chjbh ', queryparams: {'action': 'query '}" 14 Rownumbers = "true" singleselect = "true" url = "../source/jichu/chjdoc. ashx"> 15 <Thead> 16 <Tr> 17 </Tr> 18 </Thead> 19 </Table>

2. Cause Analysis and Solutions

HtmlCodeThe DataGrid is declared using the class, causing easyui to parse the DataGrid in the class declaration first when parsing the class code, so that the component requests a URL and then calls JS initialization code to request a URL. This leads to repeated loading. The solution is to declare the easyui component in only one initialization method to avoid repeated request submission, delete the class declaration (class = "easyui-DataGrid") in HTML. The modified code is as follows:

1<Table id = "DataGrid" Fit = "true" border = "false" toolbar = "# tbar" pagination = "true"213 Data-Options = "pagesize: 20, pagelist: [10, 20, 30, 40, 50,100,500 0], idfield: 'chjid', sortname: 'chjbh '"314 rownumbers = "true" singleselect = "true" url = "../source/jichu/chjdoc. ashx">415 <thead>516 <tr>617 </tr>718 </thead>819 </table>

 

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.