【发布时间】:2013-12-21 05:02:09
【问题描述】:
我正在尝试使用encodeURIComponent 函数对我的uri 进行编码。这是我的代码。
//res[0].CLIENT_ID=10 and id=res[0].CLIENT_ID
var url = "new_quotation.php?clientid="+res[0].CLIENT_ID+""eid="+id;
var encodedurl = encodeURIComponent(url);
$('#edit').attr("href", encodedurl);
它成功编码uri,但是当页面重定向时它显示错误
在此服务器上找不到请求的 URL /Quotation/new_quotation.php?clientid=10"eid=0000000014。
我看到了url。好像
http://localhost/Quotation/new_quotation.php%3Fclientid%3D10%26quoteid%3D0000000014
那么,uri 被编码了,但是为什么页面没有被重定向呢?我需要使用任何其他功能来重定向吗?还是我的代码有错误?
【问题讨论】:
-
没有理由对整个事物进行编码
-
@epascarello 你是什么意思?
-
使用
encodeURIComponent(res[0].CLIENT_ID)和encodeURIComponent(id)而不是对整个url进行编码
标签: javascript php jquery url encoding