我使用ajax jquery来发送数据到php,因为我从ajax发送了一个url作为字符串的数据,其中包含特殊字符,即"&“,所以我没有得到完整的url,也就是我检索到的数据,直到'&‘,只有rest id被忽略并且不显示。
下面是我的ajax和php代码:
dummytest.php
$temp=$_POST['address'];
echo $temp;test.html (用于发送数据的ajax)
var send="http//192..../oracle/master.php?result=2&table=1"
$.ajax({
type: "POST",
url: "dummytest.php",
dataType: "text",
data: send,
success: onSuccess,
error: onError
}); 我正在发送数据"send“,即一个url作为字符串数据,但我只在我的php中接收到"&”,即
http//192..../oracle/master.php?result=2谁能告诉我怎样才能获得完整的数据/url?
发布于 2012-06-16 15:52:54
您将URL作为POST请求的整个正文发送,而在PHP端,您希望在address参数中找到它。您应该将Javascript端的send更改为
var send = { address: 'http://...' }jQuery将负责在请求正文中对其进行编码。
发布于 2012-06-16 16:29:53
使用$(选择器).serialize()方法。serialize()方法通过序列化表单值来创建URL编码的文本字符串。
https://stackoverflow.com/questions/11061696
复制相似问题