php/ajax multipal ajx requests at a time

Discussion in 'PHP' started by Edynas, Aug 6, 2008.

  1. #1
    Hi,

    For my project i like to do something just like the Google homepage.
    Multipal ajax request at the same time and all loading content from different php pages.

    It should be done at loading the page so the obvious choise would be to make a on load statement but as far as i know i can only place 1 function there...or am i mistaken?

    Edwin
     
    Edynas, Aug 6, 2008 IP
  2. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Oh the reason why i want to use ajax in combination with php is that i have 20 php pages that all do ther thing and i only want to show the result on that page. I do'nt want to put it in 1 page and let it run thru the 20 process and wait for the whole thing to end.
     
    Edynas, Aug 6, 2008 IP
  3. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    You could easily write a javascript function that acts like a task manager. Maybe something like this:

    function Task_Manager(){
    function1(); // call the first function
    function2(); // call the second function
    function3();
    }

    Each function would use ajax to load the PHP script you want.
    So the only thing left is to call the task manager function onload.
     
    NoamBarz, Aug 6, 2008 IP
  4. ArcticPro

    ArcticPro Banned

    Messages:
    1,273
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ArcticPro, Aug 7, 2008 IP
  5. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Found the solution. Was indeed like Noam says. I was somehow thinking that if i did it like that the functions would be waiting for each other to finish before starting the next. That was not true so this works.

    Thanks
     
    Edynas, Aug 8, 2008 IP
  6. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    koolman, Aug 8, 2008 IP
  7. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #7
    KoolAjax looks good. is the multipal request synchrone and independent of the response of each request or does it wait till it's ready with all processes
     
    Edynas, Aug 9, 2008 IP
  8. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The multiple requests/responses of KoolAjax are all independent.
    It does NOT wait until all processes ready to update the page.
    Check out the UpdatePanel feature of KoolAjax, that panel makes KoolAjax special.
     
    koolman, Aug 12, 2008 IP