issue with jax-rs2.6.1 webservice+jquery
Hi,
i unable to fetch the 'json/xml' data from server,
please see the below client and server side code for your reference
i have used server jetty-7.5.4.v20111024.
client side code is:
$(document).ready(function(){
var rootURL = "http://localhost:9000/customerservice";
$.ajax(
{
Type: 'json',
type:'GET',
url:rootURL+'/get/',
crossDomain: true,
success: function(resp)
{
alert("success:");
alert(resp.age)
},
error: function(errorThrown)
{
alert("error");
}
});
});
this code connecting the server but not receive the data from server to client
Server side code:
@GET
@Produces("application/json")
@Path("/get")
public String findAll() {
JSONObject obj = new JSONObject();
obj.put("name", "lenin");
obj.put("age", new Integer(100));
System.out.println("Json Data:"+obj);
ResponseBuilder builder = Response.ok();
builder.header("Access-Control-Allow-Origin", "*");
builder.header("Access-Control-Max-Age", "3600");
builder.header("Access-Control-Allow-Methods", "GET");
builder.header(
"Access-Control-Allow-Headers",
"X-Requested-With,Host,User-Agent,Accept,Accept-Language,Accept-Encoding,Accept-Charset,Keep-Alive,Connection,Referer,Origin");
return obj.toString();
}
how to resolve the above code.
Is it possible to receive data from server (jquery 1.7.2.min.js with jax-rs 2.6.1 web service.)
reply ASAP.
Thanks in advance