1

I am trying to call cross-domain rest service using jquery as my code below:

$.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"});
   var newUrl =  "http://127.0.0.1:1338/app?restUrl=" + encodedURL; //dynamic url
    $.getJSON(newUrl, function(result){
    //response data are now in the result variable
    alert("inside");
    alert(result);
});

But when I try to execute in mozilla, I am getting this error in Firebug.

XML Parsing Error: no element found Location: moz-nullprincipal:{f8dedba7-d539-45da-a5aa-53d5ae919084} Line Number 1, Column 1:

But status I am getting in Firebug as:

GET http://localhost:1338/app?restUrl=http://localhost:9090/Bank2/service/helloRest/greet

200 OK 6ms jquery.min.js (line 18)

Because of that error, I am not able to get alerts inside getJson. Can anyone please guide me?

1 Answer 1

1

Because it's cross domain, you probably have to use JSONP

JSONP

If you are getting the above error in firebug, you are most probably making a cross browser request that is not allowed and not having invalid XML in your response. Cross browser requests are not allowed, unless you use jsonp or script as the data type.

Error explanation

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.