Hi I hava a big problem. I have to get some JSON form localhost:8080.
The server side is a restful based jax-rs server.
@Path( "/m" )
public class M {
@GET
@Path( "{id: [a-z]{1,4}-\\d{1,4}}" )
@Produces( "application/json" )
public Response getCar ( @PathParam( "id" ) final String id ) {
final ResponseBuilder builder;
builder = Response.ok( "{\"one\":\"bla\"}" );
return builder.build();
}
}
For the same origin policy I have the following script on localhost:8080/js/script.js
function test (file) {
$.ajax( {
type: 'GET',
url: file + '?callback=?',
dataType: 'json',
success: function (data) {
alert( 'works' );
}
} );
}
I don't like the '?callback=?' part, but without this the response is empty (HTTP-Body).
The problem now is, that the success method will never executed. When I change dataType to "script", the method will be called but the passed argument (data) is undefined. So what I do wrong?