0
私は正常にJSON応答を返すwebscriptを作成しました。以下を参照してください:Alfresco webscript:AJAX、JSON
get.jsファイル:
// search for folder within Alfresco content repository
var folder = roothome.childByNamePath("PATH");
// validate that folder has been found
if (folder == undefined || !folder.isContainer) {
status.code = 404;
status.message = "Folder " + " not found.";
status.redirect = true;
}
// construct model for response template to render
model.folder = folder;
get.json.ftl:
{"corporates" : [
<@recurse_macro node=folder depth=0/>
]
}
<#macro recurse_macro node depth>
<#list node.children?sort_by(["properties","name"]) as child>
{
"Name" : "${child.properties.name}",
"URL" : "${child.url}",
"serviceURL" : "${child.serviceUrl}",
"shareURL" : "${child.shareUrl}",
"ID" : "${child.id}",
"Type" : "${child.typeShort}"
},
<#if child.isContainer>
{
<@recurse_macro node=child depth=depth+1/>
}
</#if>
</#list>
</#macro>
これは(!woohoo)きれいにJSONを返しますが、私はからJSONを取得したいと思いますがAJAXを使った2番目のWebスクリプト。私はデータ型を使用するときにAJAX呼び出しが動作しない理由を私の質問がある
$(document).ready(function() {
$('.submit-button').click(function(e) {
// Avoid to trigger the default action of the event.
e.preventDefault();
// Actions declared here...
$.ajax({
type: 'GET',
dataType: 'html',
url: 'PLACEHOLDER_URL_PATH',
success: function(data) {
// Shows the result into the result panel.
$('#alfresco-result').html(data);
alert('Done.');
},
error: function(data) {
// Shows the result into the result panel.
$('#alfresco-result').html("ERROR");
}
});
});
})
:
現在、私はこのように私の第二webscriptのget.html.ftlファイル内の典型的なAJAX呼び出しを利用しています " json '?
私はAJAX呼び出しでJSONを解析し、html(例:htmlリスト)に変換したいが、受け入れ可能な入力としてJSONデータ型を受け入れていない。
ご協力いただきましてありがとうございます。
AJAXから戻って来るのは何ブラウザの開発ツールでレスポンスを見ると電話がありますか? –
ちょっと@JeffPotts、返信いただきありがとうございます。 JSON WebScriptが有効なJSONレスポンスを作成していないことに気付きました。 AJAX呼び出しは、有効なJSON応答を作成した後に完全に動作します。 – tlapinsk