我使用自定义表单,并生成表单元素与AJAX调用,但textarea的是没装的CKEditor。这是我的code:
I am using custom form and generating form elements with ajax call but textarea is not loaded with ckeditor. Here is my code:
阿贾克斯code:
jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){
$('#resp').html(response);
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
$( "#dialog-form" ).dialog( "open");
});
Ajax响应是:
ajax response is:
'<textarea class="ckeditor" cols="80" id="fname" name="fname" rows="10" >test</textarea>';
HTML code:
html code:
<html>
<head>
<script type="text/javascript" src="../include/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../include/ckeditor/sample.js" ></script>
</head>
<body>
<form>
<fieldset>
<label for="name">Name</label>
<div id="resp" ></div>
</fieldset>
</form>
</body>
</html>
请帮我解决问题。
将这些行:
ckeditor.replace('#fname'); // ADD THIS
$('#fname').ckeditor(); // ADD THIS
您code应该是这样的:
Your code should look like this:
jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){
$('#resp').html(response);
ckeditor.replace('#fname'); // ADD THIS
$('#fname').ckeditor(); // ADD THIS
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
$( "#dialog-form" ).dialog( "open");
});
上一篇:与后向服务器发送解析JSON - 为什么会发生这种Ajax调用失败?后向、发生、服务器、JSON
下一篇:angularJS和放大器; web2py的:从纳克/ javascript中调用蟒蛇/ HTML蟒蛇、放大器、纳克、angularJS