Reputation: 1367
I'm trying to get data from my url http://localhost:8080/test/rest/info
, which is json
[{"id":1,"name":"abc","age":12,"city":"la"}]
$.ajax({
type: 'GET',
contentType: 'application/json',
dataType: 'jsonp',
crossdomain: true,
url: "http://localhost:8080/test/rest/info",
success: success(),
error: fail()
});
function success(data){
alert(data);
}
function error(data, textStatus, errorThrown){
alert(textStatus);
}
success and error methods are firing, but they are returning data undefined and after is a error, where I am missing?
Upvotes: 0
Views: 368
Reputation: 27012
You need to give a function reference, not execute the function:
success: success,
error: fail
Upvotes: 1