帮助使用 YUI 将 xml 字符串/文档作为 ajax 请求提交到后台页面

发布于 2024-08-16 15:07:22 字数 124 浏览 2 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不爱素颜 2024-08-23 15:07:22

是的,使用 YAHOO.util.Connect (http://developer.yahoo .com/yui/docs/YAHOO.util.Connect.html

代码如下:

var myXmlString = "<?xml version='1.0'?>"+
                  ...
;
var conn = YAHOO.util.Connect.asyncRequest ( 
    "POST", 
    "http://myhost/mypage.aspx", 
    {
        success: function(o) { 
            ...callback...
            // o.responseXML contains the response
        },
        error: function(o){
        }
    },
    myXmlString
);

有关详细信息,请参阅文档

Yes, use YAHOO.util.Connect (http://developer.yahoo.com/yui/docs/YAHOO.util.Connect.html)

Code would go like:

var myXmlString = "<?xml version='1.0'?>"+
                  ...
;
var conn = YAHOO.util.Connect.asyncRequest ( 
    "POST", 
    "http://myhost/mypage.aspx", 
    {
        success: function(o) { 
            ...callback...
            // o.responseXML contains the response
        },
        error: function(o){
        }
    },
    myXmlString
);

See the docs for detailed infop

別甾虛僞 2024-08-23 15:07:22

使用以下代码片段传递 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
);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文