Solution for executing only once in the Ajax background

Source: Internet
Author: User
1 $. ajax ({2 URL: 'ajax/orderby. aspx ', 3 data: {appids: sortedappids}, 4 ype: 'xml', 5 type: 'post', 6 success: function (XML) 7 {8 alert ("sorted successfully! "); 9 10} 11 });

 

The first submission of AJAX is normal during synchronous interaction. If the second submission is not submitted at the same time as the last submitted URL address, the last return value is used. This may be a good deal for Ext, this requires special processing.

 

Method 1: Add parameters in get Mode

Source code:

01.var conn = Ext.lib.Ajax.getConnectionObject().conn;   02.        conn.open("get", HOST+‘/OrgUserAction_checkPassword.action?id=‘+id+‘&passwordOld=‘+checkValue,false);   03.        conn.send(null);   04.//      alert(conn.responseText);  

After modification:

01.var conn = Ext.lib.Ajax.getConnectionObject().conn;   02.        conn.open("get", HOST+‘/OrgUserAction_checkPassword.action?id=‘+id+‘&passwordOld=‘+checkValue+‘&temp=‘+new Date(),false);   03.        conn.send(null);   04.//      alert(conn.responseText);  

 

Added a temporary parameter temp = new date ();

This ensures that the URLs submitted each time are different, so that the results can be submitted each time.

Method 2:
Change get to post. Type: 'post ',

Related Article

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.