java - Ajax Post request to a Jax-rs service -


i'm trying simple post request browser , 415 unsupported media show in browser's console, in console says typeis text/html, maybe i'm mising stupid here i'm doing post request android client , find server side, guess (since i'm not familiar js) it's javascript problem i'm having here, here portions of interest of code:

ajax (this function called send , things before create json, part it's ok , tested, json being genereated successfully):

$.ajax({         url: 'webresources/serverconfig/save/',         type: 'post',         datatype:'json',         data: jsonobj     }); 

how call javascript in html form:

<form action="javascript:send()"  method="post"> 

jax-rs service:

@path("serverconfig/") public class configurationsaverservice {  @post     @path("save/")     @consumes(mediatype.application_json)     public void save(configuration configuration){     //config stuffs here. } 

edit: due @adrianplattner's answer, it's important i'm using glassfish 4.0, didn't need add jersey's dependencies, try glashfish 3.1 , still same http error.

edit 2: header:

 headers: {      'accept': 'application/json',     'content-type': 'application/json'  }, 

you can add jersey dependency:

 <dependency>      <groupid>com.sun.jersey</groupid>      <artifactid>jersey-json</artifactid>      <version>1.11</version>  </dependency> 

that should resolve ur problem


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -