简体   繁体   English

tinyMCE Jquery和PHP表单提交

[英]tinyMCE Jquery and PHP form submittion

Am trying to submit stuff typed in tinyMCE using a Jquery function but am not certain how to do that and how the server side form-processor should accept the data. 我正在尝试使用Jquery函数提交tinyMCE中键入的内容,但不确定如何执行以及服务器端表单处理器应如何接受数据。

This is what I have so far. 到目前为止,这就是我所拥有的。 Anyone see something that am missing here? 有人看到这里缺少的东西吗? I know am close. 我知道很近。 am just missing something. 只是缺少一些东西。

Thanks in advance. 提前致谢。

==THE HTML== == HTML ==

<form  onsubmit="save_tinyMCE_Stuff();" method="post" action="form_processor.php?action=save" >
  <textarea  class="classname" id="tme0" name="elm1" rows="25" cols="80" style="width: 100%" >Product Details Will appear Here. This information will be compiled by purchasing Department<br/>
  Some Text here
  </textarea><br /><input type="submit" name="save" value="Save" /><input type="reset" name="reset" value="Undo All" />
</form>

==THE SCRIPT IN HTML FILE== == HTML文件中的脚本==

save_tinyMCE_Stuff(){
  $dataString = tinymce.get('tme0').getContent();
  $zeurl = 'form_processor.php?action=save&data=' + $dataString;
  $.ajax({type: "POST",url: $zeurl,data: $dataString,cache: false,success: function(result){alert(result);}});
}

==THE PHP== == PHP ==

  form_processor.php
  <?php
if($_GET['action'] == 'save'){
  echo $_POST['WHAT NAME TO USE HERE'];
}
  ?>

If a form gets submitted, it will become available as the name attribute the element has. 如果提交表单,它将作为元素具有的name属性可用。 So for your tinyMCE stuff, it would be $_POST['elm1']; 因此,对于您的tinyMCE东西,应该是$_POST['elm1'];

Because the name of your textarea is elm1. 因为您的文本区域的name是elm1。

Getting all textarea's with jquery example: Fiddle 用jquery示例获取所有textarea: Fiddle

You don't need to tinymce. 您不需要tinecce。 Just submit textarea value. 只需提交textarea值即可。

like this: 像这样:

function save_tinyMCE_Stuff() {

    $dataString = $('textarea').val();
    $zeurl = 'form_processor.php?action=save&data=' + $dataString;
    $.ajax({
        type: "POST",
        url: $zeurl,
        data: $dataString,
        cache: false,
        success: function(result) {
            alert(result);
        }
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM