jQuery ajax POST params带有“>”符号问题(jQuery ajax POST params with “>” symbol problem)

编程入门 行业动态 更新时间:2024-10-27 02:21:43
jQuery ajax POST params带有“>”符号问题(jQuery ajax POST params with “>” symbol problem)

我正在尝试使用带有POST方法的jQuery ajax获取包含“>”符号的文本框值,但我没有使用“>”符号获取文本框值。 我已经厌倦了找到解决方案,请任何人帮我解决这个问题。

<div id="subi"><input type="textbox" id="test"><button onClick="sub()">Submit</button></div> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> function sub() { var result = { content : $('#test').val() }; alert(result); $.ajax({ url: 'subi.php', type: 'POST', contentType: "application/x-www-form-urlencoded;charset=UTF-8", data: result, dataType: 'text', success: function(html) { $('#subi').html(html); } }); } </script>

I'm trying to get a textbox value which contains ">" symbol using jQuery ajax with POST method, but I'm not getting the textbox value with ">" symbol. I'm tired of find a solution, please could anyone help me to fix this problem.

<div id="subi"><input type="textbox" id="test"><button onClick="sub()">Submit</button></div> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> function sub() { var result = { content : $('#test').val() }; alert(result); $.ajax({ url: 'subi.php', type: 'POST', contentType: "application/x-www-form-urlencoded;charset=UTF-8", data: result, dataType: 'text', success: function(html) { $('#subi').html(html); } }); } </script>

最满意答案

实际上你应该做这个服务器端(你应该在你要返回的字符串上调用htmlenties()),只是为了检查这是否有问题?

success: function(html) { $('#subi').html(escape(html)); }

Actually you should do this server side(you should call htmlenties() on the string you are returning), just to check that this is the problem does this work?

success: function(html) { $('#subi').html(escape(html)); }

更多推荐

本文发布于:2023-08-04 10:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415100.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   POST   jQuery   ajax   problem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!