2013-10-02 30 views
0

工作我使用這個jQuery代碼:

<script type="text/javascript"> 
$(document).ready(function() { 
    $("#message").hide(); 
    $("#please_wait_box").hide(); 
    $("#editcustomer").submit(function (e) { 
     $("#message").hide(); 
     $("#please_wait_box").show(); 
     e.preventDefault(); 
     dataString = $("#editcustomer").serialize(); 
     $.ajax({ 
      type: "POST", 
      url: "editcustomer_go.php", 
      cache: false, 
      data: dataString, 
      success: function (res) { 
       $("#please_wait_box").hide(); 
       $("#message").html(res); 
       $('#message').fadeIn('slow'); 
       if (res.indexOf("success") != -1) { 
        window.location.href = res.substr(8); 
       } 
      } 
     }); 
    }); 
}); 
</script> 

提交形式,而不改變頁面。

那麼editcustomer_go.php迴盪結果顯示在:

<div id="message" class="messagebox"></div> 
<div id="please_wait_box" class="messagebox">Please Wait...</div> 

我使用TinyMCE的文本編輯器 - 它的工作好,但是當數據被張貼在PHP,它沒有看到TinyMCE的文本改變的數據編輯器 - 它必須是純文本。

我該如何解決這個問題?

+2

你能解釋一下它在tinymce文本編輯器中看不到變化的數據 - 它必須是純文本。 – Archer

+1

對於較小的郵件,例如$ _POST。如果它變得更重,最好使用$ _DHL。 – djot

+0

問題標題讓我困惑。 '$ _POST'如何失效? –

回答

1

要從TinyMCE獲取數據,您需要使用它們的getContent()函數。

所以你的情況這會是

// Grab a reference to the editor 
var ed = tinyMCE.get('tinymceeditorname'); 
// Get it's content 
var editordata= ed.getContent(); 

...然後只是通過editordata與形式的AJAX調用數據的其餘一起。

+0

我在哪裏放置此代碼? – user2710234

+0

你可以在'$(「#editcustomer」)。submit()'函數中添加這兩行。然後,您需要將editordata和您從表單中序列化的其他數據一起傳遞給AJAX調用。 – danielpsc