Notes (1): for Loop ajax requests to add data

Source: Internet
Author: User

After adding multiple data entries to the master table, you must add them to the subtable based on the primary key ID of each primary table. Therefore, when you think of post submission, it is ineffective to find the cyclic post, no async parameter ..

Therefore, async in ajax sets false, and loop addition does not work ..

First writing

For (int a = 0; a <10; a ++)

{

$. Ajax ({
Url: "url ",
DataType: 'json ',
Async: false
});

}

It is found that the first data has not been executed, and the subsequent data is executed again. async does not work ..

Later, I checked the data on the Internet and wrote the final statement.

For (int a = 0; a <10; a ++)

{

Add ();

}

Function add ()

{$. Ajax ({url: "url", dataType: 'json', async: false });}

In this way, the final result is achieved. Is it because every function method produces new objects? The specific reason is unclear .. Please tell me .. There is no better solution to adding data in a similar loop

 

 

 

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.