views:

288

answers:

3

Hi there, I have a problem. I am coding using VS2008. I am calling webservices from my Javascript Page. An example

Services.ChangeDropDownLists.GetNowPlayingMoviesByLocationSVC(
            blah, 
            OnSuccessMoviesByRegion, 
            OnError, 
            OnTimeOut
        );

after execution it goes to the function OnSuccessMoviesByRegion.

But if i put the Services in a loop (a simple for loop)

   Services.ChangeDropDownLists.GetNowPlayingMoviesByLocationSVC(
                blah[i], 
                OnSuccessMoviesByRegion, 
                OnError, 
                OnTimeOut
            );

OnSucessMoviesByRegion function won't execute (but the service call executes n times successfully But i must have the function cos i am returning a value through it.

What am I missing? Is that the typical behaviour? Any alternatives?

+1  A: 

I guess there is some kind of concurrency problem. Probably you fire the next request before the last one finished.

I think you'll have to rewrite the loop. Try to move that code, calling only the first request and then using the "OnSuccess" function to call the next one each time.

splattne
A: 

Hi there, Suppose I am adding a theatre to my DB First I add the Theatre OnSuccess of it, I wanna Add theaterRows (10 nos) So the webservice is caled 10 times On each sucessRows I wanna add 10 theatreSeats for each Rows. The numbers are dynamic. How to do this?

naveen
+1  A: 

Naveen, I'm answering your follow-up question here. I can think of two options:

  1. Try to make a single call packaging your data (sending the whole blah array and handle it on the server).

  2. Use a counter variable which you decrement in the "OnSucces" client handler each time and stop if this counter variable reaches 0.

splattne