2016-01-15 33 views
1

我有一个数据webscript在户外一侧返回json响应。如何在共享webscript js文件中获取数据webscript的respose

我想共享webscript中的这个json响应来显示共享上的json数据。

以下是我用getLocation.get.js文件@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"; 
     } 

以下是从露天侧

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

您是否收到任何错误,您正在寻找在这里到底是什么? –

回答

1

使用此代码的输出,通过使用概念或RMI调用从共享侧回购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); 
    }); 
相关问题