【发布时间】:2011-03-30 23:07:19
【问题描述】:
我将自定义 XML 数据从 jQuery 发送到 Drupal/PHP,如下所示:
$.ajax({
type: 'POST',
url: this.href,
success: function(data){
alert('Form is successfully saved');
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("Error");
},
data: 'myxml='+ mydata
});
我的 XML 标记包含 URL,所以我对它们进行编码,在进行 AJAX 调用之前,数据看起来有点像这样:
mydata="<txtLinkLocation>http%3A%2F%2Fportal.cubewerx.com%2Fcubewerx%2Fcubeserv%2Fcubeserv.cgi%3FCONFIG%3Dhaiti%26SERVICE%3DWFS%26DATASTORE%3DOSM%26request%3DGetCapabilities</txtLinkLocation>";
并且,在 PHP 中,我得到接收到的数据,并将其存储如下:
$receivedXML = $_POST['myxml'];
现在,$receivedXML 的包含如下所示:
<txtLinkLocation>http://portal.cubewerx.com/cubewerx/cubeserv/cubeserv.cgi?CONFIG=haiti&SERVICE=WFS&DATASTORE=OSM&request=GetCapabilities</txtLinkLocation>
我的问题是为什么这个字符串中的 URL 会被自动解码?为什么会这样?我不希望对通过 AJAX 调用发送的数据执行任何自动操作。如何制止这种行为?我觉得我在这里遗漏了一些基本概念......
【问题讨论】: