I've found a few "solutions" but nothing seems to work for me. I'm using malsup's jquery form plugin to submit form data via POST. One of the form elements is a nicEdit box. Here's my code:

我找到了一些“解决方案”,但似乎没有什么对我有用。我正在使用malsup的jquery表单插件通过POST提交表单数据。其中一个表单元素是nicEdit框。这是我的代码:

html:

<div class="leftaligned">   
<h1>Add News:</h1>
<form enctype="multipart/form-data" id="addnewsform" action="addnewscode.php" method="POST">
<input type="hidden" name="isnewnews" value=1 />
<div class="missinginfo">
Please add a title and some content!
</div>
<h2>Title:</h2>
<input type="text" size="50" id="newtitle" name="newtitle">
<h2>Content:</h2>
<textarea style="width:590px; height:300px;" id="newcontent" name="newcontent"></textarea>
<br>
<div id="contentbuttons">
<input type="submit" value="Add News" class="submitnews" style="float:left;" /></form>
<input type="button" value="Cancel" onclick='parent.$.colorbox.close(); return false;'/>
</div>

and here's what's currently called when the submit button is clicked:

这是当点击提交按钮时当前调用的内容:

<script>
$(document).ready(function() { 
var options = {

    beforeSubmit: function(arr, $form, options) {
        var title = document.getElementById("newtitle").value;
        var content = document.getElementById("newcontent").value;
        alert(content);
        var title = document.getElementById("newtitle").value;
        if(title == "" || content == "") {
            parent.$.fn.colorbox.resize({height:635});
            $(".missinginfo").show();
            setTimeout(function()     {$(".missinginfo").hide();parent.$.fn.colorbox.resize({height:610});},2000);
            return false;
        }

    },

    success:       showResponse  
}; 

$('#addnewsform').submit(function() { 
    $(this).ajaxSubmit(options); 

    return false; 
});

function showResponse(responseText, statusText, xhr, $form)  { 
    parent.onAddNewsSuccess();
}  
});
</script>

My #newcontent text area is a nicEdit box.

我的#newcontent文本区域是一个nicEdit框。

The alert(content) displays nothing, so I know there's something else I need to do to get the text inside the nicEdit box to submit. What am I missing?

警报(内容)什么都没有显示,所以我知道我需要做一些其他事情来获取提交的nicEdit框内的文本。我错过了什么?

1 个解决方案

#1


0

(Answered in a question edit. Converted to a community wiki answer. See What is the appropriate action when the answer to a question is added to the question itself? )

(在问题编辑中回答。转换为社区维基答案。请参阅问题答案添加到问题本身时,适当的操作是什么?)

The OP wrote:

OP写道:

Nevermind, I solved it using:

没关系,我用以下方法解决了它:

    beforeSerialize: function($form, options) {
    nicEditors.findEditor('newcontent').saveContent();
},

更多相关文章

  1. Ajax php登录表单不指向另一个页面
  2. 分享27款非常棒的 jQuery 表单插件
  3. 解析PHP的基本文本输出
  4. 在体html中搜索文本的最佳方法是什么?
  5. 使用jquery animate()实现对文本的反弹效果?
  6. Jquery禁用/启用按钮与文本框代码
  7. 获取复选框的文本属性
  8. 用jQuery编写网页-表单检查
  9. jQuery中的bind绑定事件与文本框改变事件的临时解决方法

随机推荐

  1. php操作xml入门之xml标签的属性分析
  2. Java生成和解析XML格式文件和字符串的实
  3. php 修改、增加xml结点属性的实现代码
  4. php操作xml
  5. Java如何读取XML文件 具体实现
  6. Java中构造、生成XML简明教程
  7. XML和YAML的使用方法
  8. 在java中使用dom4j解析xml(示例代码)
  9. PlayFramework完整实现一个APP(十四)
  10. java解析XML几种方式小结