如何使用Tinymce 4.1.9与Raw ajax,而不是Jquery

时间:2015-04-21 04:48:20

标签: javascript ajax tinymce

我正在尝试使用Tinymice 4.1.9验证textarea,但我的代码正在处理原始ajax,因为我对jquery不太了解。问题是当我将Tinymce 4.1.9添加到我的textarea时,在验证时,我得到一个空字符串,除非我验证两次。

这就是处理验证的原始ajax看起来像

<script  language="javascript">

   function identification(identification_1,identification_2)
    {
      var OAjax;



       document.getElementById('image_loading_identification').style.display='';

      if (window.XMLHttpRequest) OAjax = new XMLHttpRequest();
      else if (window.ActiveXObject) OAjax = new ActiveXObject('Microsoft.XMLHTTP');
      OAjax.open('POST',"identification.php",true);
      OAjax.onreadystatechange = function()
      {
          if (OAjax.readyState == 4 && OAjax.status==200)
          {

          document.getElementById('image_loading_identification').style.display='none';


              if (document.getElementById)
              {   

                 document.getElementById("identification").innerHTML=OAjax.responseText;






              }     
          }
      }

      OAjax.setRequestHeader('Content-type','application/x-www-form-urlencoded');
      OAjax.send('identification_1='+ encodeURIComponent (identification_1)+'&identification_2='+ encodeURIComponent (identification_2)); 

    }

</script>

我的Tinymce 4.1.9代码

<script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script>

<script src="js/tinymce_4_1_9_jquery/tinymce/js/tinymce/tinymce.min.js" type="text/javascript"></script>
<script src="js/tinymce_4_1_9_jquery/tinymce/js/tinymce/jquery.tinymce.min.js" type="text/javascript"></script>

<script type="text/javascript">

$(function() {
   $('textarea.tinymce').tinymce({
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu paste"
    ],
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
   });
});

</script>

Html表格

<form  method="post" name="nomduformulaire_identification" id="nomduformulaire_identification" onsubmit="identification(this.identification_1.value,this.identification_2.value);return false" action="">


<div class="form-group"> 
                        <input name="identification_1" type="text" id="identification_1" class="form-control" placeholder="Name"  autofocus required/>
                    </div>

                    <div class="form-group">


<textarea id="identification_2" name="identification_2" class="tinymce"  style="width:100%"></textarea>

                    </div>    


</form> 

在此,除非我提交表格两次,否则来自identification_2的textarea输入不会收到任何内容。

如何将Tinymce 4.1.9与Raw ajax一起使用,而不是Jquery,并从identification_2字段中检索信息?

1 个答案:

答案 0 :(得分:0)

我想,在你想要读出textarea之前,你需要做:

QSqlQuery::exec()