Multiple asynchronous requests (ajax) [SOLVED]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After doing some reading, I figured out that I was causing a race condition
because my request was declared globally. I fixed this by making it local.
So, it had nothing to do with the addPoint() function, but I just saw the
affects there.

I read this here (http://developer.mozilla.org/en/docs/AJAX:Getting_Started)
on Step 3, Note 3.

~Philip


On 10/24/07, Philip Thompson <philthathril@xxxxxxxxx> wrote:
>
> Hi. I have this js function below. In it I grab the coordinates of where
> the user clicked (on the map). I want to take these coordinates and stuff
> 'em into a database, then display on the map where they clicked. Then I want
> to display some links in another div (not the map).
>
> [js code]
> function addPoint (e, imageId)
> {
>     var pl = new Array();
>     pl = map.pointLocation (e, CURRENT_POINT_SIZE);
>
>     var url = 'addPoint.php?x='+pl['x']+'&y='+pl['y']+'&size='+
>         CURRENT_POINT_SIZE+'&map='+imageId;
>     xmlHttpRequest (url, null, updateMap, 'GET');
>
>     url = 'updateForm.php?x='+pl['x']+'&y='+pl['y']+'&size='+
>         CURRENT_POINT_SIZE+'&map='+imageId;
>     xmlHttpRequest (url, null, updateForm, 'GET');
> }
>
> function xmlHttpRequest (url, vars, callbackFunction, requestMethod) {...}
> [/js code]
>
> Here, xmlHttpRequest is the method I call to perform the asynchronous
> requests. Ok, if I don't make the 2nd call to it, the points show up fine on
> the map (from the 1st request). If I make both calls, the points do NOT show
> up, but the links (from the 2nd request) appear.
>
> Is there an issue with calling this more than once? I tried setting a
> timeout for the 2nd request, but that didn't seem to help. Thoughts?
>
> Thanks in advance,
> ~Philip
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux