jquery - Accessing request parameters which are not from <form> in RESTful web services -


i trying request parameters in post method of rest service. getting null value. have tried different techniques using @formparam , request.getparameter("message") no success. have used jquery ajax client:

$("#temp1").click(function () {     var msg = $("#temp1").attr('href');     var jsonobject = {"message":msg};     var datastring = json.stringify(jsonobject);      $.ajax     ({      type: "post",     url: "http://localhost:8080/getsomerest/webresources/getfile/1",             contenttype: 'application/json',             data: datastring,             datatype: 'json',     cache: false,         success: function (data) {              var msg_data = data;             $(msg_data).appendto("#content");             $('#buttn').show();          } 

web service method:

@path("1")         @post         @consumes("application/json")         @produces("text/plain")         public string posthtml(@formparam("message") string file)throws ioexception{           system.out.println(file); //producing null     } 

html:

<body> <a id="temp1" href="d:/folder/file" >click here</a> <div id='content' style="width:640px; margin-left:450px" contenteditable="true"></div> <button id="buttn" style="position:relative; margin-top:-960px; margin-left:80%; display:block; float:left">save</button> </body> 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -