My browser unable to read the json data from arduino
Posted: Mon Feb 02, 2015 10:53 am
I want my browser to get data from arduino every 5 second using javascript/json. When the browser with javascript made the connection to arduino, the arduino replied the json
{"b1":"1234"}
but the browser was not able to read it. I have tested the javascript to read the same json data in a file from my computer and it works, but if i change the address to arduino ip, it wont work. Is there any specific header required my the script in order to read it? (i have tried to include " = "HTTP/1.1 200 OK" and everything else but it is not working. Please help......
here is my javascript,
setInterval(function(){
show();
}, 5000);
function show()
{
$.get( 'http://192.168.1.104/!0Z', function( data ) {
$('#B1').show(); // 2pm
$('#b1').html( data.b1 ).show(); // 2pm
}, "json");
}
{"b1":"1234"}
but the browser was not able to read it. I have tested the javascript to read the same json data in a file from my computer and it works, but if i change the address to arduino ip, it wont work. Is there any specific header required my the script in order to read it? (i have tried to include " = "HTTP/1.1 200 OK" and everything else but it is not working. Please help......
here is my javascript,
setInterval(function(){
show();
}, 5000);
function show()
{
$.get( 'http://192.168.1.104/!0Z', function( data ) {
$('#B1').show(); // 2pm
$('#b1').html( data.b1 ).show(); // 2pm
}, "json");
}