473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

asynchronous javascript

9
hi

is there a way to execute a js function async so that the UI is not frozen. something like starting a new thread :) to do something else. i don't know if this is possible, but I was thinking why not, because you can make an async web service calls?! So is there a way to do it?
May 10 '07 #1
9 1978
iam_clint
1,208 Expert 1GB
sure use ajax. and write to a div.

if this isn't what your talking about please reply with a more detailed question.
May 10 '07 #2
r035198x
13,262 8TB
hi

is there a way to execute a js function async so that the UI is not frozen. something like starting a new thread :) to do something else. i don't know if this is possible, but I was thinking why not, because you can make an async web service calls?! So is there a way to do it?
Ajax my friend, ajax.
May 10 '07 #3
gits
5,390 Expert Mod 4TB
yes ... thats right ... ajax is it ;) otherwise the question is not specific enough ... the purpose of ajax is to make asynchronous requests to a server ... that results in a more responsive web-ui -> the browser will not be blocked during the request - the corresponding callback-function is called when the response is available ... that is real slick ;) ... besides that, there should be no need to make an async call to a javascript function, one that don't need to get a server-response (new data or something like that)?
May 10 '07 #4
vanko
9
yes ... thats right ... ajax is it ;) otherwise the question is not specific enough ... the purpose of ajax is to make asynchronous requests to a server ... that results in a more responsive web-ui -> the browser will not be blocked during the request - the corresponding callback-function is called when the response is available ... that is real slick ;) ... besides that, there should be no need to make an async call to a javascript function, one that don't need to get a server-response (new data or something like that)?
NO, this is not the issue i'm facing. :(
I don't want to make a request to the server, I want to do some javascript job :)...do some html parsing that takes some time. And the problem is that during that time I want to do something else in javascript. Is this possible? The effect should be like starting a new thread in C# or Java to do something. I hope you got the idea now...
May 10 '07 #5
iam_clint
1,208 Expert 1GB
sadly i don't believe theres a way to multithread in javascript :( sorry

you would need to do ajax queries.
May 10 '07 #6
gits
5,390 Expert Mod 4TB
yes ... there is no multithreading in js ... but, to work around it: you may do an ajax request ... parse your things on the server -> you may pass the data to it, compute it and deliver it back or something like that - shouldn't be impossible ;) but sounds strange - think you have a really huge amount of data to parse through? may be you want to sort or filter the delivered data on clientside? perhaps it makes sense to do a new query that delivers the sorted or filtered data from the database? ... and: meanwhile you would have the browser to do other things ... besides that, you could try to optimize datahandling on the client ... you may give the client a javascript object that holds the data within, and instead of parsing through html-elements you handle the data of that js-object ... works fine for a lot of our applications ... even with huge amounts of data ... short description of that idea is: write a 'data-object' in js with load and data-handling-methods -> do an ajax request for required data -> deliver it as json to the client -> the data-object stores it -> now do the requests to this objects data ... every interface-action uses that data from now on -> we don't parse with dom methods only create, replace or delete elements ... data handling works on native js-objects or arrays ...
May 11 '07 #7
r035198x
13,262 8TB
yes ... there is no multithreading in js ... but, to work around it: you may do an ajax request ... parse your things on the server -> you may pass the data to it, compute it and deliver it back or something like that - shouldn't be impossible ;) but sounds strange - think you have a really huge amount of data to parse through? may be you want to sort or filter the delivered data on clientside? perhaps it makes sense to do a new query that delivers the sorted or filtered data from the database? ... and: meanwhile you would have the browser to do other things ... besides that, you could try to optimize datahandling on the client ... you may give the client a javascript object that holds the data within, and instead of parsing through html-elements you handle the data of that js-object ... works fine for a lot of our applications ... even with huge amounts of data ... short description of that idea is: write a 'data-object' in js with load and data-handling-methods -> do an ajax request for required data -> deliver it as json to the client -> the data-object stores it -> now do the requests to this objects data ... every interface-action uses that data from now on -> we don't parse with dom methods only create, replace or delete elements ... data handling works on native js-objects or arrays ...
Yep, Javascript should not be used for doing lots of extensive work. I think the OP is better of doing the extensive operations on the server side.
May 11 '07 #8
vanko
9
yes ... there is no multithreading in js ... but, to work around it: you may do an ajax request ... parse your things on the server -> you may pass the data to it, compute it and deliver it back or something like that - shouldn't be impossible ;) but sounds strange - think you have a really huge amount of data to parse through? may be you want to sort or filter the delivered data on clientside? perhaps it makes sense to do a new query that delivers the sorted or filtered data from the database? ... and: meanwhile you would have the browser to do other things ... besides that, you could try to optimize datahandling on the client ... you may give the client a javascript object that holds the data within, and instead of parsing through html-elements you handle the data of that js-object ... works fine for a lot of our applications ... even with huge amounts of data ... short description of that idea is: write a 'data-object' in js with load and data-handling-methods -> do an ajax request for required data -> deliver it as json to the client -> the data-object stores it -> now do the requests to this objects data ... every interface-action uses that data from now on -> we don't parse with dom methods only create, replace or delete elements ... data handling works on native js-objects or arrays ...
Deam...:) i knew that this won't be possible. It will really be cool if there would be a way to do multithreading in js, don't you think :))
I think I got the idea...just to use object oriented javascript code :)
10x for the answer
May 11 '07 #9
gits
5,390 Expert Mod 4TB
Deam...:) i knew that this won't be possible. It will really be cool if there would be a way to do multithreading in js, don't you think :))
I think I got the idea...just to use object oriented javascript code :)
10x for the answer
yep - that would be cool ... and while doing it with a server turnaround you could 'emulate' it -> of coures with all drawbacks that this affects: traffic, server-performance, etc. ... you would use the server as a quasi-co-processor ... don't really know whether this is an good idea or not ... but if there is a possibility to finetune the data-requests you need for specific situations ... then you should ask the database again with an ajax-request ... it is not allways a good idea to get all the data and handle it on the client ... let every tier in our multi-tier-chain do what it can do best

using oo-js is always a good idea ... for all the reasons for that oo is a good idea at all ... wish you luck with it ...
May 11 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jiayanxiang | last post by:
Is there any sample code to use Javascript to load and display a text file? It will be best if the user can select files using some kind of explorer. If that's complex, a text box to specify the...
8
by: jpaul | last post by:
Hi I am very new to this two If the browser disable the javascript, what happen to Ajax? can i slove the problem by using server side script? any suggestion for this? i currently do some dirty...
6
by: RC | last post by:
Is AJAX built on top of JavaScript? What browsers supported AJAX? Can someone tell me some link introduce about AJAX?
5
by: turnitup | last post by:
Dear all, I have a JavaScript function that talks to php using ajax. It can return values from php. Up until now, I have used it to return simple values such as integers or text strings. ...
2
by: Jeff | last post by:
I'm still new to all of this - mostly vb.net using vs 2005, so I might not be using good terminology but let me give my question a try: I'm looking for someone to point me in the correct...
3
by: Nightcrawler | last post by:
I recently moved over a bunch of functionality to use javascript and webservices. I ran into the issue where a webservice taking longer than 10 seconds to respond will cause Firefox to throw a fit...
4
by: Rex the Strange | last post by:
Seriously. I have a flash animation that I was trying to run during ajax calls - sort of eyecandy - but it would freeze whenever the ajax call was being made. Then I found out it wasn't just the...
4
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.