problem with multiple ajax HTTP get requests with different imput variables using jQuery

Posted by Thanasis on Stack Overflow See other posts from Stack Overflow or by Thanasis
Published on 2010-05-21T18:53:53Z Indexed on 2010/05/21 20:20 UTC
Read the original article Hit count: 239

Filed under:
|
|
|
|

I want to make asychronous get requests and to take different results based on the input that I provide to each one. Here is my code:

param=1;
$.get('http://localhost/my_page_1.php', param, function(data) {
   alert("id = "+param);
   $('.resul   5.t').html(data);
});

param=2;
$.get('http://localhost/my_page_2.php', param, function(data) {
   alert("id = "+param);
   $('.result').html(data);
});

The result for both requests is: "id = 2" I want the results to be: "id = 1" for the 1st request, and "id = 2" for the second one..

I want to do this for many requests in one HTML file and integrate the results into the HTML as soon as they are ready.

Can anyone help me to solve this problem?

thank you in advance, Thanasis

© Stack Overflow or respective owner

Related posts about get

    Related posts about AJAX