2

I can't post images as a new user so I have added links to the images.

After about 3 days of modifying my backend, battling with browser compatibility and actually getting my code to work I have managed to make a call to a java rest service in dojo and managed to get a "200 Ok" status but I am not able to get the Json response object even when try to dig deep into my "response" object.

Code For Calling The Service

script.get("http://192.xxx.xx.xx:8080/com.thinkingpa.web/SecurityResourceService/loginUser", {
                    jsonp: "callback",
                    query: {
                        emailAddress:"email@email.com",
                        password:"password"
                    }
                }).then(function(response){

                    //Help me out here everything I've tried has failed me!

                });
});

My Response Object in a funciton

function(response)

As you can see in the creen shots attached below when I debug in firebug I do manage to get the json in the relevant "response" and json tabs.

Firebug Response Tab

Response tab in Firebug

Firebug JSON Tab

JSON tab in Firebug

How do I display/get the data either from the Json or response tabs into an alert box (message window)

  • Possible duplicate.Please check this [enter link description here][1] [1]: http://stackoverflow.com/questions/7112672/jquery-ajax-call-to-rest-service – Prabash B Sep 20 '12 at 08:42
  • Looks like you should be able to just use alert(response[2]); or alert(response.nameSurename); to output the nameSurname for instance.. – AardVark71 Sep 20 '12 at 10:53
  • Sorry for the delay... @AardVark71 I tried alert(response[2]) and it returns Undefined. Is there something I am missing here? –  Sep 25 '12 at 13:05
  • Sorry Mazi, I misread your post.. my previous comment was incorrect. You might want to check this SO link _http://stackoverflow.com/questions/8847573/where-does-the-response-get-stored-after-a-dojo-jsonp-request_ as the approved answer explains how you can specify a callback function. – AardVark71 Sep 25 '12 at 15:28
  • Found out what the issue was. I moved my restful services to the same server on which the application is running and without even changing code it returns the object in the "then" function. Thanks. –  Sep 28 '12 at 04:02
  • @AardVark71 used your method to extract the response from the response object thanks. –  Sep 28 '12 at 13:37

0 Answers0