2017-11-11 83 views
1

HTML代碼無法從CKEditor的全面檢索PHP文本

<form name='form' method='post'> 
    <textarea name='ckeditor'></textarea> 
    <input type='submit' name='submit' value='Save' /> 
<form> 

JavaScript代碼

$(document).submit(function(event){ 

event.preventDefault(); 

$editor = CKEDITOR.instances['editor'].getData(); 

//alert($editor); 

    $.ajax({ 
    method: "POST", 
    url : "someurl", 
    data : "full_text="+$editor, 
    success = function (response) { 
     alert(response); 
    } 
    }); 
}); 

PHP代碼

<?php 
    print_r($_POST["full_text"]; 
?> 

當Java腳本內部使用提醒我的全文所示。但是當使用php的print_r函數時,只顯示兩行或三行文本。

如果我有三段文字提示顯示所有三段,但php只顯示兩行。下面是更詳細的圖片

第一張圖片在提交之前顯示javascript內部警報。

第二個圖像顯示從PHP頁面警報響應 alert of textarea inside javascript

alert from ajax

+0

您是否嘗試將包含data =「full_text =」+ $ editor的行更改爲data:{full_text:$ editor}? – msantos

+0

是的,我已經嘗試過。仍然沒有結果。但我發現如果只使用print_r($ _ POST);它顯示全文 – whoknows

回答

0

$.post將是一個簡單的POST請求更容易。

$.post("someurl", {full_text: $editor}, function(response){ 
    alert(response); 
})