2

我似乎无法从我的 ckeditor 那里获得价值,我有什么想法会出错吗?

<textarea  class="ckeditor" id="Source"></textarea> 
<a href="javascript:void(0);" onclick="SendPreview()" class="pOrange"> Send</a>
function SendPreview() {
        var value = CKEDITOR.instances['Source'].getData();
        var model = { EmailBody: Source, EmailTo: "email@email.com", EmailSubject: $(".Subject").val() };
        var request = $.ajax({
            url: '/Campaign/SendPreviewEmail',
            type: 'POST',
            dataType: 'JSON',
            data: { model: JSON.stringify(model) },
            cache: false,
            success: function (data) {
                var dataAsString = JSON.stringify(data);
            }
        });
    }
4

2 回答 2

8

你有什么工作,问题是因为你将 CKEditor 的值设置为value变量,但是Source在你的model. 尝试这个:

var value = CKEDITOR.instances['Source'].getData();
var model = { 
    EmailBody: value, // <-- Change this
    EmailTo: "email@email.com",
    EmailSubject: $(".Subject").val() 
};
于 2013-09-04T07:36:22.077 回答
2

检查以下内容,这可能会帮助您获得解决方案

var value = CKEDITOR.instances['Source'].getData();

    //or
    $('#Source').ckeditor(function( textarea ){
      $(textarea).val();
    });
于 2013-09-04T07:40:50.627 回答