Skip to main content
 首页 » 编程设计

javascript之使用 Prototype 发布复杂的 JSON 对象

2025年05月04日54cmt

我正在使用 Prototype 1.6.1 在 IIS 下使用 ASP 和 Python 创建应用程序。

Python 正在生成一个复杂的 JSON 对象。我想通过 AJAX 请求将此对象传递到另一个页面,但原型(prototype)文档对我来说有点太狡猾了。

谁能告诉我如何创建一个原型(prototype) AJAX.Request 来发布一个 JSON 对象,然后打印出“好的,我知道了”或类似的东西?

Vielen 潮湿!

请您参考如下方法:

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...') } 
});