473,560 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLHTTPRequest streaming data

I am playing with the XMLHTTPRequest method to perform client/server
transactions. I have it set up right now so that when readyState is 4,
it takes the XML and processes it. This works great until there is alot
of data. In that case, the user will have to wait for the data to come
back which may take a minute or so.

I don't want the user to have to wait. Is it possible for javascript to
periodically (while still receiving more data) stop and display what it
has received thus far? I guess this would be considered a type of
streaming.

In mozilla/firefox, I have read that I can use readyState 3 to run my
callback function every 4096 bytes. I can then take those 4K, parse
them, and then continue on. However I have also read that IE cannot do
this. Since I need this to work in IE, is there a workaround?

Thanks,
Scott

Jul 23 '05 #1
22 5606
go**********@sc ottsavarese.com wrote:
I don't want the user to have to wait. Is it possible for javascript
to periodically (while still receiving more data) stop and display
what it has received thus far?


Not that I know of.
One suggestion - use JSON instead of XML. Or use your own compact data
structure.

XML is verbose, and you may be able to cut down your transmission time if
you use a data format that is more compact.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 23 '05 #2


go**********@sc ottsavarese.com wrote:

In mozilla/firefox, I have read that I can use readyState 3 to run my
callback function every 4096 bytes. I can then take those 4K, parse
them, and then continue on. However I have also read that IE cannot do
this. Since I need this to work in IE, is there a workaround?


You should be able to access responseText once readyState gives you the
value 3 for interactive.
From the MSXML docs for XMLHTTP:

(3) INTERACTIVE Some data has been received. You can call the
responseBody and responseText properties to get the current partial
results.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3


Martin Honnen wrote:

You should be able to access responseText once readyState gives you the
value 3 for interactive.
From the MSXML docs for XMLHTTP:

(3) INTERACTIVE Some data has been received. You can call the
responseBody and responseText properties to get the current partial
results.


I have done some tests here trying to access responseText when
readyState is signalled as 3 but unfortunately MSXML then always gives
an exception that the data necessary is not yet available so in this
case it looks like the docs are promising more than is possible.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
Martin Honnen wrote:
(3) INTERACTIVE Some data has been received. You can call the
responseBody and responseText properties to get the current partial
results.


However, with XML it needs to be well-formed and parsed before being
available, afaik.
You can get to the responseText, but it won't be XML that can be
manipulated.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 23 '05 #5
Matt Kruse wrote:
Not that I know of.
One suggestion - use JSON instead of XML. Or use your own compact data
structure.


I'll look into JSON. Right now our XML is pretty compact. The structure
is very little overhead as compared to the data itself. I am more
worried by the shear number of data rows we may return than anything
else.

I was playing around with Mozilla. It doesn't seem to hard to keep
track of how much data I've read so far and use substring to extract
the latest. Then parse the latest information and present it to the
user.

However with IE, I can't use the readyState variable. Plus I tried
using a timer (every second) to read the responseText and IE comes back
with an error. Is there anyway to get the partial response from IE or
do I have to wait until it completes? Is there any hack I can do to IE
to get it to work?

Thanks,
Scott

Jul 23 '05 #6
On 22 Jun 2005 12:40:41 -0700, go**********@sc ottsavarese.com wrote:
However with IE, I can't use the readyState variable. Plus I tried
using a timer (every second) to read the responseText and IE comes back
with an error. Is there anyway to get the partial response from IE or
do I have to wait until it completes? Is there any hack I can do to IE
to get it to work?


No, just use the IFRAME remote scripting method and JSON, it's much
more reliable and cross-platform for achieving what you want, although
it's the server that has to do the breaking up.

Jim.
Jul 23 '05 #7
Martin Honnen wrote:
I have done some tests here trying to access responseText when
readyState is signalled as 3 but unfortunately MSXML then always gives
an exception that the data necessary is not yet available so in this
case it looks like the docs are promising more than is possible.


I get the same thing... That is exactly what I am trying to get around.

Scott

Jul 23 '05 #8
Jim Ley wrote:
No, just use the IFRAME remote scripting method and JSON, it's much
more reliable and cross-platform for achieving what you want, although
it's the server that has to do the breaking up.


I really like the idea of JSON. Unfortunately in this case, I need my
protocol to be XML. The code can't be language specific. If I was just
using a web browser to obtain the information from the server, then
JSON can be used, and may even be better, however I also have a perl
client side module, and I have a feeling my users are going to want a
Java one as well. How is JSON with security... I run the returned value
in a eval block. Of the examples I've seen everyone seems to trust that
the data returned is valid and not harmful. Can you craft a JSON reply
that does something malicious?

As for the IFRAME piece, I did some research on it... Is there an
example on line of people doing the type of streaming that I am looking
for? Also, it looks like the IFRAME seems to imply a need to use GET as
opposed to POST (as it updates the history). Is that true?

Scott

Jul 23 '05 #9
On 22 Jun 2005 13:37:20 -0700, go**********@sc ottsavarese.com wrote:
Jim Ley wrote:
No, just use the IFRAME remote scripting method and JSON, it's much
more reliable and cross-platform for achieving what you want, although
it's the server that has to do the breaking up.


I really like the idea of JSON. Unfortunately in this case, I need my
protocol to be XML.


No, you need to provide an XML protocol, that doesn't mean the one you
provide to your website is XML, a server XML->json is entirely
appropriate solution - especially as IFRAME's (which require JSON to
do this) are the only way you're going to get the incremental approach
in IE.

As for a link, no idea, you just need to write out an HTML document
with

<script type="text/javascript">
.... block 1
</script>

<script type="text/javascript">
.... block 2
</script>

<script type="text/javascript">
.... block 3
</script>

etc.

Jim.
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1442
by: WildHare | last post by:
What exactly is streaming? When I use a browser or an application and it gets streaming data (say, Headlines, Stock Quotes, etc), what is it really doing. Is it just that the client is constantly making new requests for information from a given web server, or is there more magic to it? It sounds like we are opening a connection and getting...
5
1555
by: John | last post by:
Hi all, I have an (well, what I think to be, at least) interesting question: Is it possible to stream data down to the client and, after a certain amount of data has been streamed, allow the client to begin interacting with that data whilst still streaming data down? Also, if it is possible, how would one go about coding this? Would some...
6
2710
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios, every now and then the client would timeout and have to re-initiate the request... TIA!
2
9742
by: mpaliath | last post by:
Hi guys I am currently involved in a project which requires me to recieve and play streaming video as well as send it. In Visual C++ is there any free library which helps me do this as 'streaming' is not part of the actual project, i am allowed to use external libraries. Also could anyone tell me where I can learn about video streaming in...
3
4680
by: Vijay | last post by:
Hi Folks, I having one issue, in my application I am going to use the server push for streaming the data by keeping the connection open. At client side, i am having the XMhttprequest object (i.e ActiveX object of IE). When the data comes, onreadystatechange method get callback on state 3 but it doesn't allow me to read the data from the...
1
4017
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to...
1
5289
by: Tarik Monem | last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest. Can I use PHP do what I'm trying to do? Here's my code: The function mySaveFunction() is called by clicking the "Update" button, after the user changes the data which is populated in...
5
3535
by: pmakoi | last post by:
dear all this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic I am writing a web service that uses soap with attachments to send a large streaming data, The concept works quite well but when I started to test it I got...
2
4982
by: Wizfrog | last post by:
Hello, I'm working with a pretty large XML file, but I really only need to display a few things that requires quite a few transforms. I already limited to the transforms to the data i need to use, but I'd like to speed things up by loading only the data I need. I need to mention that this is for a local application that sometimes will...
0
7841
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8066
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7920
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6191
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5458
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5175
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3605
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.