• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restrict multiple calls of function

 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I have created a tree in javascript whose nodes calls a function
for example

Now this function takes approx. 30-40 seconds to complete,
and if i click on this node,the function starts its processing
and if in the meantime i click on the other nodes,it generates an error

This happens due to multiple requests of the script,
i wish to block request until response of one is rendered,
i have also tried to do this with a flag called allowrequest,but the ealier script dies as soon as the new request arrives.



Please advice what to do in this case and how can i restrict another call until one response completes.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a processing flag saying an action is happening so do no process. Also add an annimation graphic or message to the user omething is happening.

Eric
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply eric,
Is there no way to stop this by programming?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
30 to 40 seconds to complete a task is pretty outrageous. What's it doing? An Ajax request? I have many Ajax requests that do intensive processing and that return almost instantly. What's taking so long? Perhaps that's what you should be conentrating on.

Also, there's no inherent reason that your page can't be doing multiple things at a time. What is the cause of the error that you are seeing?
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bibeault,

Thanks for your time,
It's an Ajax request which GETS 9 JSP pages and renders the response on the page.

The cause of the error is when i click multiple nodes and that too very quickly,i get the error



if you want,i can post the code for further reference.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an Ajax request which GETS 9 JSP pages and renders the response on the page.


But what is taking so long? And 9 JSPs? That's rather odd.
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers/Bibeault,

Please have a look at the page
Products

Choose Electrical Appliance
Then Select Barbeque.
The dummy data in the database has one or maximum two products for the other categories,the barbeque has 31 i suppose.

Each page shows 9 slides at a time which are Ajax calls for JSP page
Slide.jsp

Slide.jsp picks the data from database and takes every Full Image and then resizes it with a GD library + PHP file.

Your suggestions and comments are invited.
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

One more thing the Client has asked to remove the Working On Your Request window,which locks the tree for further request.His opinion is that if a person clicks a wrong category by mistake he has to wait for the products to load of that category,which he is not encouraging.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I though you meant 9 serial JSPs (as opposed to parallel). That would have been very odd.

It all worked fairly quickly for me, with the "working window" being displayed for only a few seconds.

I agree with the client -- that's a rather unfrienldy way to be dealing with your JS bug. Your new plan, which seems to be to ignore the user clicks, isn't any friendlier.

You should be able to simply abort the pending Ajax requests when the user selects something else from the tree, and start over. It's a matter of properly structuring the code.

There's obviously a lot of client side code for that page -- a lot of which seems to be auto-generated dreck from Dreamweaver or similar tool -- so it's hard to give you any concrete suggestions at this point other than to use good coding patterns and object-oriented techniques.

To start with, you'll need to isolate what causes the bad reference when the tree gets clicked on a second time.
[ April 29, 2007: Message edited by: Bear Bibeault ]
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear/Ranchers,

Thanks for sparing your valuable time,
Please See that i have removed the Working.. Window,
When i am clicking the nodes quickly its generating the error on IE6 and IE7,and as we know netscape and mozilla have some javascript debugging window but that's of no use as it works perfectly on mozilla as well as netscape.

Please Check i really need some help on this as i am not able to trace the bug.I can pass the source code as well as a FTP access to the server for the modifications and testing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic