帮助使用 YUI 将 xml 字符串/文档作为 ajax 请求提交到后台页面
我想在 aspx 页面上创建 XML 字符串,然后使用 YUI ajax 请求将此请求提交到另一个 aspx 页面进行处理。所以 1.是否可以通过像我们在ajax响应上所做的那样设置一些ajax请求配置来实现这一点? 2.如何做到?
I would like to create the XML string on the the aspx page and then submit this request using the YUI ajax request to another aspx page for the processiong. So
1. is this possible by setting some of the ajax requests configurations like we do on ajax response ?
2. How it can be done ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,使用 YAHOO.util.Connect (http://developer.yahoo .com/yui/docs/YAHOO.util.Connect.html)
代码如下:
有关详细信息,请参阅文档
Yes, use YAHOO.util.Connect (http://developer.yahoo.com/yui/docs/YAHOO.util.Connect.html)
Code would go like:
See the docs for detailed infop
使用以下代码片段传递 xml。它还可以用于传递 JSON 数据。
<代码>
YAHOO.util.Connect.setDefaultPostHeader(false);
YAHOO.util.Connect.initHeader("Content-Type", "application/xml; charset=utf-8");
var myXmlString = '测试数据';
var conn = YAHOO.util.Connect.asyncRequest (
“发布”,
“背景页.aspx”,
{
成功:函数(o){
div.innerHTML = "成功" + o.responseText;
},
错误:函数(o){
div.innerHTML = "错误";
}
},
myXmlString
);
xml is passed using following code snippet. It can also be used to pass the JSON data.
YAHOO.util.Connect.setDefaultPostHeader(false);
YAHOO.util.Connect.initHeader("Content-Type", "application/xml; charset=utf-8");
var myXmlString = 'TEST DATA';
var conn = YAHOO.util.Connect.asyncRequest (
"POST",
"BackgroundPage.aspx",
{
success: function(o) {
div.innerHTML = "Success" + o.responseText;
},
error: function(o){
div.innerHTML = "Error";
}
},
myXmlString
);