1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I run more than one AJAX request at a time?

Discussion in 'JavaScript' started by Imozeb, Mar 2, 2010.

  1. #1
    Is there anyway I can run more than one AJAX request at a time?
     
    Imozeb, Mar 2, 2010 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Create two separate request objects and assign them different onreadystatechange handlers.
     
    Logic Ali, Mar 2, 2010 IP
  3. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Okay. Thanks, but now I'm running into this problem. The first AJAX request updates a file via post and the second one reads the file via get. For some reason the reading of the file only works once, when the page first loads, after that it doesn't read the updated data unless I close the browser and open my page again. Why is this and how can I fix it?
     
    Imozeb, Mar 2, 2010 IP
  4. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #4
    The browser is probably reading cached data, which you should be able to prevent by sending a randomly-generated parameter in the read request.
     
    Logic Ali, Mar 2, 2010 IP
  5. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Okay. Thanks!
     
    Imozeb, Mar 3, 2010 IP