Results of disordered requisitions

Asked

Viewed 26 times

0

I have 1 textarea with several lines, to each line of this textarea I have data to make a post request in a single url, it checks each line and sends me the result on the screen via jquery, the problem is that the results that are printed on the screen are not sorted according to the data placed in the textarea, it should print the results in the form of a list of lines 1, 2, 3, 4 of the textarea in sequence, but it prints this disorderly 4, 2, 1, 3 it checks if a proxy and port work example 292.168.391.34|8080 and made the request on a page placing the data before the | separator in the proxy input and after the separator in another port input, and with preg_match capturing the connected message and with a if do print on the screen the message whether it was successful or not together next to the line tested, more always the results come back cluttered not hitting as the sequence in the textarea as I solve this ?

1 answer

0

You need to note that ajax is asynchronous so it can give you the answer to a request that was made after one was made before. So to solve this you could make the first request and then in the callback function of that perform the other and so on, in the order you need. I don’t know the jquery syntax, but here’s an example:

function callback2 () {
    ajax3(callback3);
}
function callback1 () {
    ajax2(callback2);
}
ajax1(callback1);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.