如何通过ajax发布ckeditor html值

时间:2016-03-17 06:41:31

标签: jquery ajax

var editor_data = CKEDITOR.instances.editor1.getData();
var editor_data2 = CKEDITOR.instances.editor2.getData();

var post_formdata =$('#product_add')+'&shortdesc= '+editor_data+'&fulldesc= '+editor_data2;

        $.ajax({
            url:"seller-panel-product-add-data.php",
            type:"POST",            
            data: post_formdata,            
            dataType:'html',
            success:function(data){         
              alert("Data was succesfully captured");

            },
            error: function(data) {               
               alert("Error");
            }
        });

2 个答案:

答案 0 :(得分:0)

用此修改:

$.ajax({
        url:"seller-panel-product-add-data.php?shortdesc= "+editor_data+"&fulldesc="+editor_data2,
        type:"POST",                       
        dataType:'html',
        success:function(data){         
          alert("Data was succesfully captured");

        },
        error: function(data) {               
           alert("Error");
        }
    });

答案 1 :(得分:0)

var editor_data = CKEDITOR.instances.editor1.getData();
var editor_data2 = CKEDITOR.instances.editor2.getData();

$.ajax({
    url: 'seller-panel-product-add-data.php',
    type: 'POST',
    data: {
        shortdesc: editor_data,
        fulldesc: editor_data2
    },
    dataType: "html",
    success: function(data){ 
        alert("Data was succesfully captured");     
    }
    error: function(xhr, status, error) {               
       alert("Error with reason: "+xhr.responseText);
    }
});