javascript - Access JSON data inside brackets - home({"a": { "prop1": "data", "prop2": "data"}); -
i'm getting result when calling service below.
call:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> function getdata() { var clientid = '123'; var pagename = 'home'; var serviceurl = 'https://service.com/meta?_callback=home&_o=' + clientid + '&_t=' + pagename + ''; $.ajax({ url: serviceurl, method: 'get', aynch:true, success: function (data) { console.log(data); }, error: function (data, textstatus, errorthrown) { alert('service call error '+ errorthrown); } }); } </script>
response:
home({ "a": { "prop1": "data", "prop2": "data" }, "b": { "prop1": "data", "prop2": "data" } });
how access data of result using javascript ?
this looks lot jsonp response!
have read on jsonp (http://en.wikipedia.org/wiki/jsonp)
<!-- call api --> <script src="http://api.url.com?callback=home"></script> <script> // handle response function home(data) { console.log(data); } </script>
Comments
Post a Comment