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)); }更多推荐
发布评论