SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast Pablasso's Avatar
    Join Date
    Jun 2003
    Location
    Guadalajara, Mexico
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple request via Prototype to PHP?

    Hello.

    I have a problem requesting several responses at the same time. I launch something like this (using prototype):

    Code JavaScript:
    Event.observe (window,'load',function(){
        someFunction("a");
        someFunction("b");
        someFunction("c");
        someFunction("d");
       // etc ...
    }
     
    function someFunction(parameter) {
            var url = "/example.php";
            var pars = "par=" + parameter;
            var MyAjax = new Ajax.Request(
                url,
                {
                    method: 'post',
                    parameters: pars,
                    onSuccess: someCallback
                });
    }
     
    function someCallback(originalRequest){
        // does something
    }

    My big problem is that example.php is not getting called simultaneously, instead, just 2 request per time get called.

    If i launch 4 request (A,B,C,D). A and B get called first, and C won't start if any of the first two aren't finished, same goes for D. (example.php needs several seconds before getting completed depending on the parameters).

    I need to launch around 20 requests, so processing them in pairs makes the wait unacceptable.

    What could my problem be? the way I'm calling the PHP script? PHP configuration? Apache configuration? How can i request them all at the same time?

    Thanks a lot for your help

  2. #2
    SitePoint Zealot Caged's Avatar
    Join Date
    May 2003
    Location
    United States
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try setting the asynchronous option to false. Note the warning in the documentation though about doing this: http://prototypejs.org/api/ajax/options

  3. #3
    SitePoint Enthusiast Pablasso's Avatar
    Join Date
    Jun 2003
    Location
    Guadalajara, Mexico
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no luck, it's even worse as every request gets processed one by one (as denoted by asynchronous:false)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •