How to read JSON data, that is sent from Android, using Javascript? -
i have created mobile application scans surrounding bluetooth devices , able put devices array list.
now, using http post method, have send jsonobject having array list url , have written expected code on android app(i sure code work because have worked on using post method url's , displaying response on activity).
but, how listen jsonobject, sent android app url, parse , show on particular url's webpage ? (in short looking javascript code can handle , show list.)
if have url json being posted can do:
plain js:
var request = new xmlhttprequest(); request.open('get', 'url', true); request.onload = function() { if (request.status >= 200 && request.status < 400) { // success! var data = json.parse(request.responsetext); } else { // reached our target server, returned error } }; request.onerror = function() { // there connection error of sort }; request.send();
with jquery:
var getdata = $.getjson('url'); getdata.done(function(data){ // have access data here });
Comments
Post a Comment