title: Set Value of CodeMirror textarea from Jquery Ajax Call
body: <p>I'm trying to get a value from a Ajax call in Jquery to a the value property of a Textarea that's using, CodeMirror scripts.
  I've tried the classic way to set the .html() and .val() properties of the textarea to my Ajax call data, parameter.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>&lt;!--Replaces TextBoxes by the code oriented boxes--&gt;
  &lt;script type="text/javascript"&gt;
    var editor = CodeMirror.fromTextArea(document.getElementById('code'),{
      mode: 'shell',
      lineNumbers: true,
      theme: 'blackboard'
    });
  &lt;/script&gt;
  &lt;!--Jquery Scripts for the Selects and file Edit--&gt;
  &lt;script type="text/javascript"&gt;
    $(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 &amp;&amp; "file="+file,
        cache: false,
        success: function(data){
          //alert(data);
          //var file_result = data;
          $("#code2").setValue(data);
        },
        error: function(msg){
          $("#error_loading_file").show()
        }
      });
   })
  </code></pre>
  
  <p>
  I'm running out of ideas!</p>