I have made a Rest Web Service:
package org.jboss.samples.rs.webservices;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.GET
I think that you are not returning a valid json: try something like:
return "{\"name\":\"unknown\", \"age\":-1}"
because this
{
"name": "unknown",
"age": -1
}
is a valid JSON (You must use "
, not '
) while this is not
{
'name': 'unknown',
'age': -1
}
You should also specify the datatype
$.ajax({
type: "GET",
url: "http://localhost:8080/nagarro-0.0.1-SNAPSHOT/MyRESTApplication/dealInfo/2",
dataType: "json",
success: function(resp){
// we have the response
alert("Server said123:\n '" + resp.name + "'");
},
error: function(e){
alert('Error121212: ' + e);
}
});