论坛首页 Web前端技术论坛

prototype 发送XML数据的问题。

浏览 14405 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-11-14  


toQueryString 里就是用了 encodeURIComponent(如我在2楼所说)
这里prototype应该支持一个开关就好了


0 请登录后投票
   发表时间:2007-11-14  
谢谢Fins的回答,那这个应该是Prototype的一个缺陷了。。
0 请登录后投票
   发表时间:2007-11-14  
不是缺陷,post提交数据就应该编码,不编码还发送什么url-encoded的header呀,post get的参数编码是默认的,不编码是错误的,具体会有什么潜在问题,到不是太清楚,可能主要是中文吧,特殊字符可能问题还不大
0 请登录后投票
   发表时间:2007-11-14  
afcn0 写道
不是缺陷,post提交数据就应该编码,不编码还发送什么url-encoded的header呀,post get的参数编码是默认的,不编码是错误的,具体会有什么潜在问题,到不是太清楚,可能主要是中文吧,特殊字符可能问题还不大

要不是缺陷,那为什么不按我的编码方式传递数据呢?
0 请登录后投票
   发表时间:2007-11-14  
你那是不编码,post提交是必须要编码的,任何一个XHR包装器都是这样,jQuery Prototype dojo ext sack...
0 请登录后投票
   发表时间:2007-11-14  
The Content-Type header for your request. You might want to send XML instead of the regular URL-encoded format, in which case you would have to change this. 文档说了,你可以改变contentType试试
0 请登录后投票
   发表时间:2007-11-14  
哪个就是自定义requestheader和编码没有关系,可以看Prototype1.60第1230行
this.setRequestHeaders();

和1260行
      headers['Content-type'] = this.options.contentType +
        (this.options.encoding ? '; charset=' + this.options.encoding : '');

对于编码没有影响,就是帮助服务器识别text/xml;类型的,具体怎么处理还得看服务器具体怎么弄的
0 请登录后投票
   发表时间:2007-11-14  
笨笨狗 写道
The Content-Type header for your request. You might want to send XML instead of the regular URL-encoded format, in which case you would have to change this. 文档说了,你可以改变contentType试试



你好,我都改过了,代码如下:
<script>
function AAAA()
{
var tt = "<root><name>student</name><age>12</age></root>";
var myAjax = new Ajax.Request(
'http://localhost:8080/queryData',
{method: "post", encoding: "utf-8" ,contentType: "aplication/x-www-form-urlencoded",
parameters: tt, onComplete: showResponse}
);
function showResponse(originalRequest)
{

}

}
</script>
0 请登录后投票
   发表时间:2007-11-15  
contentType: "text/xml" 试试
0 请登录后投票
   发表时间:2007-11-15  
试了,也没有用
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics