AnsweredAssumed Answered

Extract dataObj values ???

Question asked by yascorp on Apr 29, 2014
Latest reply on Apr 29, 2014 by yascorp
Hello,
I have done an ajax.request to send data to a specific url

html.ftl

<javascript>
function generateForm() {

var title = new YAHOO.util.Element('${args.htmlid}-title');
var title_v = title.get('value');
var description = new YAHOO.util.Element('${args.htmlid}-description');
var description_v = description.get('value');
var category = new YAHOO.util.Element('${args.htmlid}-category');
var category_v = category.get('value');
   
var data = {               
            title : title_v,
            description : description_v,
            category : category_v
         };
        
Alfresco.util.Ajax.request(
               {   
                   url: Alfresco.constants.PROXY_URI + "api/form/add-news",
                   method: Alfresco.util.Ajax.POST,
                  dataObj:
                     {
                        site: Alfresco.constants.SITE,                        
                        dataValues: JSON.stringify(data)                        
                     },
                  
                  successCallback:                                          
                     {                     
                        fn: function generateForm_onSuccess(response) {
                           var res = response.serverResponse.responseText
                           var dataString = JSON.stringify(data);                                                   
                           console.log("Loading success !" + dataString);   
                           console.log("Loading success !" + res);                                                      
                        },
                        scope: this
                     },
                  failureCallback:
                     {
                        fn: function generateForm_onFailure(response) {
                           console.log("Loading failed …");
                        },
                        scope: this
                     },   
                  execScripts: true
               });
}
</javascript>


my add-news.post.js
<javascript>
                var siteId = json.get("site");
      
      var jsonData = json.get("dataValues");
      
      var siteRoot = siteService.getSite(siteId);
      
      logger.log("ADDNEWS : SITEID" + siteId);               
      
      // Convertir le native JS object to string
      //var objtoString = jsonUtils.toJSONString(jsonData);
      var objtoString = String(jsonData);
      model.objtoString = objtoString;
      
      logger.log("ADDNEWS : objtostring : " + model.objtoString);
</javascript>

I get this error : "json" is undefined ???

so how can I get "site" & "dataValues" VALUES ???



please help me,
thnx & regards

Outcomes