我通過php將它的內容發送給javascript,從而生成一堆tinymce編輯框。jQuery從PHP腳本接收html變量的問題
我做這樣的事情
<script>
addBox('<?$content?>');
</script>
的問題是,每次發送的文本具有一個「/」字符的功能被打破了返回一個錯誤,如:
Uncaught SyntaxError: Unexpected token ILLEGAL
我發現它至少用這個字符返回這個錯誤......不知道它是否會與其他人發生。這個函數在調用時出錯,如:
addBox("<p>Fundada em 2000 e inserida no <strong>Grupo CIL</strong>, a CilNet &eacute; uma empresa de Servi&ccedil;os de Engenharia na &aacute;rea das Tecnologias de Informa&ccedil;&atilde;o, com compet&ecirc;ncias em Redes de Comunica&ccedil;&atilde;o de Dados, Voz e V&iacute;deo.</p>
<p>Tendo como base uma larga experi&ecirc;ncia no mercado nacional, a CilNet assume-se como um parceiro tecnol&oacute;gico no sector empresarial, com especializa&ccedil;&atilde;o em solu&ccedil;&otilde;es tecnol&oacute;gicas pioneiras a n&iacute;vel mundial.&nbsp;</p>");
任何人都可以幫忙嗎?
爲addBox的代碼如下:
function addBox(text){
elem = "txt" + window.counter;
var tiny = $.ajax({
type: "POST",
url: "inc/ajax.php?act=inserebox",
data: "value=txt" + window.counter + "&text="+encodeURIComponent(text),
async: false
}).responseText;
$('.more_boxes').append(tiny);
//$(tiny).append('.more_boxes');
tinyMCE.init({
url:'../js/tinymce/jscripts/tiny_mce/plugins/ibrowser',
mode:"exact",
elements: elem,
theme:"advanced",
height:"220",
entity_encoding : "raw",
plugins : "safari,pagebreak,style,table,advimage,advlink,emotions,iespell,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,inlinepopups,ibrowser",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false
});
window.counter+=1;
return true;
}
addBox在做什麼?絕對聞起來像一個編碼問題。 –
問題是在addBox調用不在函數本身... – jribeiro
你試過解碼你的Html嗎?http://www.opinionatedgeek.com/dotnet/tools/htmlencode/decode.aspx –