2012-07-25 44 views
1

我找到了一些“解决方案”,但似乎没有任何工作适合我。我使用malsup的jQuery表单插件通过POST提交表单数据。其中一个表单元素是nicEdit框。这里是我的代码:通过ajax 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> 

和这里的点击提交按钮时,什么是目前所谓:

<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> 

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

警报(内容)什么也没有显示,所以我知道还有其他事情我需要做,才能让nicEdit框内的文本提交。我错过了什么?

回答