1

I have one data webscript at alfresco side which return json response.

i want this json response in share webscript to display that json data on share.

following is the my code written in getLocation.get.js file @ share.

      var result1 = new Array();
      var connector = remote.connect("alfresco");
      var data = connector.get("/com/portfolio/ds/getlocation");

        // create json object from data
      if(data.status == 200){
      var result = jsonUtils.toJSONString(eval(data.response));
        model.docprop = result ;
         }else{
         model.docprop = "Failed";
        }

Following is the output from alfresco side

     { 
        "subgroups": [
        {
        "name": "grp_pf_india_user" ,
            "label": "INDIA"
         }, 
    {
      "name": "grp_pf_israil_user" ,
      "label": "ISRAIL"
     }, 
    {
      "name": "grp_pf_usa_user" ,
      "label": "USA"
      } 
     ]
     }
4

1 回答 1

1

使用此代码通过使用概念或 RMI 从共享端调用 repo webscripts。(Alfresco.constants.PROXY_URI) = ( http://host:port/share/proxy/alfresco/ )

var xurl=Alfresco.constants.PROXY_URI+"HR-webscripts/createHRDocument/"+JSON.stringify(o);
    //alert(xurl);
    var request = $.ajax({
        url: xurl ,
        type: "POST",
        //data: { "groupname" : o},
        beforeSend : function(xhr){
            /*
            Alfresco.util.Ajax & alfresco/core/CoreXhr – will automatically take the token from the cookie and add it as a request header for every request.
            Alfresco.forms.Form – will automatically take the token from the cookie and add it as a url parameter to when submitting an multipart/form-data request.
            (When submitting a form as JSON the Alfresco.util.Ajax will be used internally) 
            */                  
            if (Alfresco.util.CSRFPolicy && Alfresco.util.CSRFPolicy.isFilterEnabled()){    
                xhr.setRequestHeader(Alfresco.util.CSRFPolicy.getHeader(), Alfresco.util.CSRFPolicy.getToken() );
            }
        },
        dataType: "html"
    });

    request.done(function(msg) {
       //alert( "Request OK: " + msg );
      $("#res").html( msg );
    });

    request.fail(function(jqXHR, textStatus) {
      alert( "Request failed: " + textStatus );
    });
于 2016-03-05T04:33:14.863 回答