how to read json response from cloudify rest api using jquery? -


i need fetch json data cloudify rest url (remotehost) http://hostname:8100/service/applications/.

this url returns following json response:

{     "response": {         "petclinic": ""     },     "status": "success" } 

i've tried response code below:

$.getjson("http://hostname:8100/service/applications?jsoncallback=?", function (result) {     $.each(result, function (i, field) {         $("div").append(field + " ");     }); }); 

i checked request net panel in firebug, showing 200 ok status, can't json data. error bellow appears in console:

console error

same origin

assuming call made same domain (e.g. you're deploying local cloud, , call made locally, , sends request localhost:8100), should able succeed performing rest calls, provided remove ?jsoncallback=? request url.

this suffix url serves request wrapper function on response, , used jsonp (javascript-object-notation padding) type requests. in order use jsonp server must support - cloudify rest api not - such requests fail, origin.

cross origin

if you're trying run different domain of rest server, won't work regardless. rest api not allow cross origin resource sharing either. meant use servers, create service makes calls rest api , serve client that. can put jquery xhr calls on client, calling own service.

further reading


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -