谷歌关闭XhrIo

max*_*max 6 json google-closure

我是Google Closure的新手,我想知道XhrIo是如何工作的.我已阅读XHRIO http://code.google.com/closure/library/docs/xhrio.html的概述

基本上,我正在关注这个例子,但我无法让它发挥作用.我使用eclipse和tomcat作为我的服务器来执行示例.有人可以告诉我如何在html,使用goog.require的java脚本('goog.net.XhrIo')之间建立连接; 和json文件?感谢你们.

Max*_*nce 10

以下是发布帖子请求的示例:

goog.require('goog.Uri');
goog.require('goog.net.XhrIo');

var qd = new goog.Uri.QueryData(); 
qd.add('name1', 'val1'); 
qd.add('name2', 'val2'); 
function done(e) { 
   this.getResponseText();
   this.getResponseJson();
}  
goog.net.XhrIo.send('/controller/action', done, 'POST', qd.toString());
Run Code Online (Sandbox Code Playgroud)