从客户端javascript我想调用一个返回JSON数据的share-webscript。
getTicket.json.ftl的响应如下:
{
"ticket" : "TICKET_faf851d4a993b62c98908268af07876f09fa86c9"
}
那么如何从我的客户端javascript调用这个share-webscript并提取“ticket”的值呢?
see answer below
答案 0 :(得分:1)
答案:
Alfresco.util.Ajax.jsonGet(
{
url: Alfresco.constants.PROXY_URI + "/auth/getTicket.json",
successCallback:
{
fn: function(response)
{
try {
var json = JSON.parse(response.serverResponse.responseText);
var ticket = json["ticket"];
if (ticket.substring(0, 6) == "TICKET") {
clipboardData.setData("Text", ticket + "&" + file.nodeRef);
location.href = Alfresco.constants.URL_RESCONTEXT + "components/javawebstart/AEF_JNLP.jnlp";
} else {
// handle unknown format
}
} catch (e) {
// handle error
}
},
scope: this
},
failureCallback:
{
fn: function(response)
{
// handle failure case
},
scope: this
}
});
这会调用共享层webcript。所以你还需要一个共享层webscript,它调用一个存储库web脚本,它返回实际的票证......