如何在 YUI 中向 Django 服务器发出 XHRDataSource 请求?
我正在使用 post,YUI 文档示例代码不起作用。
YAHOO.util.Event.addListener(window,"load",function()
{
var columnDefs =
[
{key:"url", sortable:true, resizeable:true},
{key:"title", sortable:true, resizeable:true},
{key:"count", sortable:true, resizeable:true}
];
this.dataSource = new YAHOO.util.DataSource("/getallsites/");
this.dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
this.dataSource.connMethodPost = true;
this.dataSource.responseSchema =
{
fields:["url","title","count"]
};
this.myDataTable = new YAHOO.widget.DataTable("siteTable",columnDefs,this.dataSource,
{initialRequest:"/getallsites/"});
});
/getallsites/ 返回一个 JSARRAY。在将 JSARRAY 转换为 JSON 之前,我想让它正常工作。 Django 服务器日志甚至无法识别对 /getallsites/ 的请求。有什么想法吗?
谢谢!
I'm using post, and the YUI documentation example code isn't working.
YAHOO.util.Event.addListener(window,"load",function()
{
var columnDefs =
[
{key:"url", sortable:true, resizeable:true},
{key:"title", sortable:true, resizeable:true},
{key:"count", sortable:true, resizeable:true}
];
this.dataSource = new YAHOO.util.DataSource("/getallsites/");
this.dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
this.dataSource.connMethodPost = true;
this.dataSource.responseSchema =
{
fields:["url","title","count"]
};
this.myDataTable = new YAHOO.widget.DataTable("siteTable",columnDefs,this.dataSource,
{initialRequest:"/getallsites/"});
});
The /getallsites/ returns a JSARRAY. I wanted to get the JSARRAY to work before I converted it to JSON. The Django server log isn't even recognizing a request to /getallsites/. Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,确保页面上包含连接管理器实用程序。
其次,按照您的配置方式,请求将转到/getallsites//getallsites/,因此请尝试将initialRequest 设置为“”。
First, make sure you are including the Connection Manager utility on the page.
Second, the way you have it configured, the request will go to /getallsites//getallsites/, so try setting initialRequest to "".