[JQuery Mobile, PhoneGap]: Getting undefined response in my ajax call from the java web service
This is my Ajax Call:
var url="
http://192.168.1.6:8080/RESTfulProject/REST/VmsAccess/GetUsers/admin/jsonp";
$.ajax({
url: url,
type: "GET",
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
jsonpCallback: 'successCallback',
success: function(res, status)
{
console.log("Ajax Call Success............");
//var parsed_data = JSON.parse(res);
//var json = $.parseJSON(res);
console.log(res.responseText+"-----------"+status);
/*res = $.parseJSON(res.responseText);
console.log(res.admin_name)*/
//testing param
if( p == 'admin') {
//store
window.localStorage["username"] = u;
console.log("Login Success......"+ u);
$.mobile.changePage("#mainPage");
} else {
//navigator.notification.alert("Your login failed", function() {});
console.log("Login Failed......");
}
$("#submitButton").removeAttr("disabled");
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 500) {
console.log('Internal error: ' + jqXHR.responseText);
} else {
console.log('Unexpected error...'+jqXHR.responseText);
}
},
async: false,
cache: false
});
This is My Webservice:
@GET
@Path("/GetUsers/{username}/jsonp")
@Produces(MediaType.APPLICATION_JSON)
public Response feed(@PathParam("username") String param1)
{
String feeds = null;
try
{
ArrayList<FeedObjects> feedData = null;
ProjectManager projectManager= new ProjectManager();
feedData = projectManager.GetFeeds(param1);
//StringBuffer sb = new StringBuffer();
Gson gson = new Gson();
System.out.println(gson.toJson(feedData));
feeds = gson.toJson(feedData);
} catch (Exception e)
{
System.out.println("error");
}
//return "successCallback(" +feeds+ ");";
return Response.ok("successCallback(" +feeds+ ");").header("Access-Control-Allow-Origin", "*").build();
}
I am getting output:
Calling Ajax----------
Ajax Call Success---------
undefined------------success