Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old February 8th, 2010, 04:40 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 5
Unhappy Firefox addon, JS and Ajax - help needed

Ok guys, need a bit of help, i hate to admit that but im tearing my hair out

Ok firstly, do not shout when i tell you this but i have been running ajax synchronously in my functions for my firefox addon, simply because i have to grab 10 posted iterations of a page, each may have a different result (good/bad/fail) and i need to tally them up and display the user with a final result.

old way was setting the async value in the xmlhttprequest to false, i still need to do this from what i understand of it, but i believe i can do so without freezing the users browser by using threads (ooooh threads you say)

ok heres how that would work:
Code:
 backgroundTask = {
   run: function() {
     // I am putting my synchronous ajax code in here
   }
 }
 
 var thread = Components.classes["@mozilla.org/thread-manager;1"]
                        .getService(Components.interfaces.nsIThreadManager  )
                        .newThread(0);
 thread.dispatch(backgroundTask, thread.DISPATCH_NORMAL);


which is from the mozilla site, but not working for me.

Then i read that you can run stuff in the background by using something like :

Code:
  var thread = Components.classes["@mozilla.org/thread-manager;1"]
                        .getService(Components.interfaces.nsIThreadManager  )
                        .currentThread;
 while (!complete)
   thread.processNextEvent(true);



my question is this, does anyone know how i can run 10 synchronous ajax calls in the background without freezing the users browser? (they know it will happen and accept it, but they should NOT be putting up with my crappy coding stopping them for the duration of the ajax calls).

i believe my solution is in threads, anyone want to help?
__________________
When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.

Reply With Quote
  #2  
Old February 9th, 2010, 05:52 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 5
ok how about forget the whole firefox addon bit, and maybe a bit of help with javascript and threading?

so I need a way to run xmlhttprequest with async flag set to false (as i need to read the response before proceeding) while not freezing the users browser?

something similar can be seen here:

http://sitepointstatic.com/examples...ading/test.html

(just need to remove the "counter" and set that with the ajax call)

Reply With Quote
  #3  
Old February 12th, 2010, 04:04 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 5
Never mind, found a way to do it, this thread can be closed.

Reply With Quote
  #4  
Old February 12th, 2010, 10:43 AM
IAmALlama IAmALlama is offline
Me
Click here for more information
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,120 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 6 Days 20 h 31 m 26 sec
Reputation Power: 6
I would personally just return one JSON object with all posted pages and return that. Even if you had to use php to get the results and act as a proxy (ie ajax contacts a php script on your site and that script gets the 10 posted pages and sends an object back with all 10 responses).

And that test you put a link to did slow down my browser and this is not a slow computer. When I clicked on the X to close the tab, it took a few seconds before it would close and before that the buttons seemed non-responsive.

Reply With Quote
  #5  
Old February 12th, 2010, 10:46 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 5
im just going to use web workers, create one, that creates and monitors multiple subworkers, then returns the value and appropriate responses when its complete, absolutely no interference to the user since as far as he knows its happily working giving him an update on the screen as it proceeds, simply implemented, new feature and, the most important part, does not disturb browsing.

oh and that link i provided simply messed with timing, and delegation so its not true multithreading so, although it did slow your computer down, it did not freeze it like my current way does.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Firefox addon, JS and Ajax - help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.


© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek