使用encodeURI组件并在服务器端对其进行解码
Using encodeURIcomponent and decoding it on server side
我使用encodeURI组件向这样的服务器发送了一个url作为请求参数的一部分
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd3Dcd&_=1332612418587
这就是服务器所看到的:
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd
尽管我之前用encodeURI组件再次将它插入数据库,但我得到了一个错误,即在数据库中找不到它。
这个url的格式如下,尽管我再次将其插入encodeURI组件之后。我猜mysql在将其插入列之前将其转换为常规类型。
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd
我该如何解决那个问题?知道吗?
这是我的插入代码:
$.ajax({
type : "GET",
url : '/tree/insertResult/?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title)+'&folder='+folderName+'&snippet='+encodeURIComponent(snippet),
cache : false,
success : function(res) {
if(res == "F")
notification("Operation Failed", "You have that bookmark in that folder!");
else{
folderName = res;
notification("Operation Suceeded", "Bookmark has been created.");
updateFolderContent(url, title, folderName, snippet);//it is in _filetree_javascript.html.erb
}
},
error : function(x, y, z) {
alert(x.responseText);
}
});
}
这是我的提取代码:
$.ajax({
type : "GET",
url : '/tree/deleteResult/?title='+encodeURIComponent(title)+"&url="+encodeURIComponent(url),
cache : false,
success : function(res) {
if(res == "F") //if F is returned from server it means "There is a folder with same name"
notification("Operation Failed", "Bookmark cannot be deleted! Sorry :(");
else
notification("Operation Succeed", "Bookmark've been deleted.");
deleteResult(domObj);
},
error : function(x, y, z) {
alert(x.responseText);
}
});
}
我通过在服务器上解码字符串来解决这个问题。我在rails 中使用了CGI宝石
CGI::unescapeHTML(url)
相关文章:
- 如何使用skip参数使用angular ui引导进行服务器端分页
- Webpack开发服务器和React服务器端渲染
- 提示使用服务器端事件处理程序激活JavaScript
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- 如何轻松地将服务器端变量从Java代码转移到客户端代码
- 通过ajax将坐标传递到php服务器端,并在处理后检索到javascript
- 将表单数据提交到服务器端
- 使用ajax的服务器端分页&jQuery
- 显示具有服务器端自动时间注销的同步倒计时计时器
- 使用FormData上传AJAX图像;t在服务器端显示图像
- React路由器服务器端渲染和ajax获取数据
- renderReact/Rect Router+Node/Express.js的服务器端/同构渲染中未定义renderP
- Meteor如何运行服务器端python脚本
- CORS-服务器端cookie没有保存在chrome浏览器上
- 加载服务器端渲染的React组件后执行脚本
- 在Javascript中复制C#服务器端验证
- 使用encodeURI组件并在服务器端对其进行解码
- jQuery服务器端多数据解码
- 是否在服务器端存储未解码的jwt令牌
- 在javascript中编码查询字符串并在asp.net-mvc服务器端正确解码的正确方法是什么?