ajax中itemtexts,从Jquery Ajax调用CodeMirror textarea的值设置
我試圖從Jquery中的Ajax調(diào)用中獲取值到正在使用CodeMirror腳本的Textarea的value屬性。 我已經(jīng)嘗試了將textarea的.html()和.val()屬性設(shè)置為我的Ajax調(diào)用數(shù)據(jù)參數(shù)的經(jīng)典方法。從Jquery Ajax調(diào)用CodeMirror textarea的值設(shè)置
這里是我的代碼:
var editor = CodeMirror.fromTextArea(document.getElementById('code'),{
mode: 'shell',
lineNumbers: true,
theme: 'blackboard'
});
$(document).ready(function() {
var directory = $("#directory").val();
$.ajax({
type: "POST",
dataType: "text",
url: "list_directory.php",
data: "directory="+directory,
cache: false,
success: function(data){
$("#files").html(data)
},
error: function(msg){
$("#starterror").show()
}
});
});
$("#directory").change(function(){
var directory = $("#directory").val();
//$("#aux_directory").val(file);
//alert(file);
$.ajax({
type: "POST",
dataType: "text",
url: "list_directory.php",
data: "directory="+directory,
cache: false,
success: function(data){
$("#files").html(data)
},
error: function(msg){
$("#starterror").show()
}
});
})
$(".edit_item").live('click',function(){
var directory = $("#directory").val();
var file = $(this).text();
$.ajax({
type: "POST",
dataType: "text",
url:"edit_file.php",
data: { directory: directory, file: file},
//data: "directory="+directory && "file="+file,
cache: false,
success: function(data){
//alert(data);
//var file_result = data;
$("#code2").setValue(data);
},
error: function(msg){
$("#error_loading_file").show()
}
});
})
我跑出來(lái)的想法!
+0
嘗試使用editor.setValue() –
+0
謝謝aljordan82,它現(xiàn)在是OK! –
與50位技術(shù)專家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的ajax中itemtexts,从Jquery Ajax调用CodeMirror textarea的值设置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: .ajax跳过不执行,使用ajax跳过路
- 下一篇: 怎么提高es服务器的性能,es集群服务器