I want to read live streaming data from my URL(ie.http://..) My URL(ie.http://..) contain numeric data and it's continuously growing. i want to read that data in to my file(HTML5 & javascript). I have done with static numeric data using AJAX. But while duing it with dynamic data(live streaming data). i am not able to get responseText(). Is it possible to take responseText() of that URL(ie.http://..) which contain live streaming data? how i can do this? My code for reading static data is
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function accessWebservice()
{
var xmlhttp;
xmlhttp = new XMLHttpRequest();
//xmlhttp.open("get","http://192.168.15.174/Streamer/StartStream.aspx?IsTestData=true",true);
//above URL contains live streaming numberic data that i want to read
//But when i am using above URL i am not getting responseText (**How to get it?**)
xmlhttp.open("get","http://localhost/StaticDemoData.txt",true); //This contains static data
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4)
{
if (xmlhttp.status == 200 )
{
var responseData=xmlhttp.responseText;
alert(responseData);
}
else
{
alert("Server returned: " + xmlhttp.status);
}
}
}
xmlhttp.send(null);
}
</script>
</head>
How to get 'xmlhttp.responseText' for live streaming numeric data?
If you check for xmlhttp.readyState == 3
(XMLHttpRequest.LOADING), then accessing xmlhttp.responseText
will give you the data that has been received from your server so far. You can then use a setInterval to constantly check xmlhttp.responseText
for new data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With