2009-09-29 72 views
1

我使用Prototype 1.6.1在IIS下使用ASP和Python創建應用程序。使用原型發佈複雜的JSON對象

python正在生成一個複雜的JSON對象。我想通過AJAX請求將這個對象傳遞給另一個頁面,但Prototype文檔對我來說有點太狡猾。

有人可以告訴我一個如何創建一個原型AJAX.Request的例子,發佈一個JSON對象,然後打印出「好的,我明白了」或類似的東西?

Vielen dank!

回答

7
new Ajax.Request('/some_url', 
{ 
method:"post", 
postBody:"{'some':'json'}", 
onSuccess: function(transport){ 
    var response = transport.responseText || "no response text"; 
    alert("Success! \n\n" + response); 
    }, 
onFailure: function(){ alert('Something went wrong...') } 
}); 
+0

爲了擴大這一點,你可以設置'postBody'到'JSON.stringify(可變)'有JSON構建了你,那麼它也樹立了良好的實踐'contentType'到'應用/ JSON '以及。 – Malvineous 2016-08-24 12:00:42