[英]jQuery and AJAX call for element have JavaScript code?
I have a simple form which has only one textarea
element. 我有一个只有一个textarea
元素的简单表单。
We use this text area to pass JavaScript code and save it into a MySQL database using PHP. 我们使用此文本区域传递JavaScript代码,并使用PHP将其保存到MySQL数据库中。
It works fine with any text, but not with text which has the JavaScript 它适用于任何文本,但不适用于具有JavaScript的文本
$(function(){
$("#hotbar").submit(function(){
$.ajax({type:'POST',
url: 'modules/hotbar.php',
data:$('#hotbar').serialize(),
beforesubmit : function() {
return $('#hotbar').validate().form();
},
success: function(response) {
$('#action').html(response);
}
});
return false ;
});
});
It works fine with any text only; 它仅适用于任何文本; when passing the JS code we want to save it does nothing and never lets the value pass to the PHP page 传递JS代码时,我们要保存的代码不会执行任何操作,并且永远不要让该值传递给PHP页面
没有更多细节很难说,但是我首先要检查jQuery验证插件或服务器端的某些表单处理组件是否正在删除脚本标签,以尝试保护您免受跨站点脚本(XSS)攻击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.