1
我使用CKeditor和一个文件输入元素。我通过FormData传递它在Jquery Ajax中。这里是我的Jquery函数。将HTML样式属性从Javascript传递到PHP
function sample(){
var cmtWRITE=CKEDITOR.instances['cmtWRITE'].getData();
var vpb_files = document.getElementById('vpb-data-file').files;
var vpb_data = new FormData();
$.each(storedFiles, function(keys, values)
{
vpb_data.append(keys, values);
});
vpb_data.append('cmtWRITE', cmtWRITE);
console.log(cmtWRITE); // here just for confirmation
for (var pair of vpb_data.entries()) {
console.log("### "+pair[0]+ ', ' + pair[1]); // here just for confirmation
}
$.ajax({
url: base_url+'aaa/xxxx',
type: 'POST',
data: vpb_data,
cache: false,
processData: false,
contentType: false,
dataType : 'html',
beforeSend: function()
{
//doing some process
},
success: function(response)
{
//doing response
},
error:
function(e){
console.log('Error while request..'+JSON.stringify(e));
}
});
}
在PHP函数由
$txt=$this->input->post("cmtWRITE");
获取值,当我回声$ TXT或直接这个 - $>输入 - >交的( “cmtWRITE”),其打印为:
<p>Okay<em> </em><span [removed]>Noted</span></p>
但在控制台实际值是
<p>Okay<em> </em><span style='color:#ff0000'>Noted</span></p>
她我通过CK编辑器添加了字体颜色。但在PHP方面得到[删除],这使得不添加样式字体。 这里我的ckeditor Init
CKEDITOR.replace("cmtWRITE", {
// Define the toolbar groups as it is a more accessible solution.
toolbarGroups: [
{"name":"basicstyles","groups":["basicstyles"]},
{"name":"links","groups":["links"]},
{"name":"paragraph","groups":["list","blocks"]},
{"name":"insert","groups":["smiley"]},
{"name":"styles","groups":["TextColor"]},
{"name":"colors","groups":["TextColor"]}
],
// Remove the redundant buttons from toolbar groups defined above.
removeButtons: 'Strike,Subscript,Superscript,Anchor,Specialchar,Image,Source,About,Flash,Table,SpecialChar,Iframe,HorizontalRule,PageBreak',
height:'100px'
//removePlugins: 'clipboard',
});
在此先感谢。请帮我解决这个问题
您是否检查网络监视器以确定风格是通过电线发送的?如果是这样,输入对象是否消毒来自用户的任何html? –
我没有让你@juan – Gopalakrishnan