cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get parameters in javaback

xinyieric
Champ in-the-making
Champ in-the-making
Hi,

in surf, i submit a  post request use jquery ajax,
then how can i get the json parameters in javaback?
when i use req.getParameter(), it return null…

surf code:

   $.ajax({
         url : Alfresco.constants.PROXY_URI + "aegis/demo/javabacked",
         type : "POST",
         data : {"test":"aaa","test1":"bbb"},
         dataType : "json",
         contentType : "application/json",
         success : function(response) {
            alert("success");
         },
         error : function() {
            alert("error");
         }
   });

javabacked code:

   protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
      
      Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
      
      System.out.println(">>>>>>>>>>>>test = " + req.getParameter("test"));
      System.out.println(">>>>>>>>>>>>test1 = " + req.getParameter("test1"));
      
      return model;
   }

thanks
3 REPLIES 3

gyro_gearless
Champ in-the-making
Champ in-the-making
I suppose it's "dataObj:" instead of "data:" in the AJAX invocation….

HTH
Gyro

xinyieric
Champ in-the-making
Champ in-the-making
I suppose it's "dataObj:" instead of "data:" in the AJAX invocation….

HTH
Gyro

thanks for your answer.
but how to resolve this problem?

best regards.

gyro_gearless
Champ in-the-making
Champ in-the-making
Sorry, i didn't notice that you are using jQuery to do AJAX… here of course "data:" seems to be right, sorry for the confusion!

Basically your Webscript should be fine, so perhaps you have to get a trace on what request is actually sent by jQUery  :roll:

And, by the way, why are you using an extra framework when Alfresco already comes with YUI? Although i'm a big fan of jQuery, you should think twice before mixing two frameworks…

Cheers
Gyro