issue with jquery client getting jsonp data from restfull webservice
how to send the response to jquery client as josn data.
this is my jquery code for getting data to client
var url= 'http://10.163.14.56:9000/customerservice/renderdetails?callback=?';
$(document).ready(function(){
$('#getData').click(function() {
$.ajax({
type: 'GET',
url: url,
async: false,
crossDomain:true,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(json) {
alert("success") ;
alert(json.name);
// console.dir(json.sites);
},
error: function(e) {
alert("error"+e.toString());
}
});
});
});
i have used jax-rs 2.6.1 framework in restfull webservice for server side code
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/renderdetails")
public Response get_Det(){
// String json ="{symbol: 'IBM', price: 91.42}";
String data="{"
+"\"age\":100,"
+"\"name\":\"otcnic\" "
+"}";
System.out.println("JSON Data:"+data);
return Response.ok(data, MediaType.APPLICATION_JSON).build();
}
please let me know what i made mistake,
i am getting the following error in client side :
error[object Object]
Timestamp: 08/08/2012 09:58:02 AM
Error: SyntaxError: invalid label
Source File: http://10.163.14.56:9000/customerservice/renderdetails?callback=jsonCallback&_=1344400082000
Line: 1, Column: 1
Source Code:
{"age":100,"name":"otcnic" }
if any body having server side RESTfull(apache cxf2.6.1) web service and client side in jquery code please share it.
it would be help for me.
thanks in advance
G.Lenin
Research Scientist
OTC-NIC