2010-10-21 27 views
0

我想用jquery抓取div的內容並將其傳遞給通過電子郵件發送的php腳本。所以我需要使用$('#div')。html()並將其發送到$ _POST ['']值。有任何想法嗎?jquery選擇要發佈的值

回答

3

(從jQuery的docs):

$.ajax({ 
    type: "POST", 
    //your PHP file 
    url: "some.php", 
    //passing contents $_POST['body'] will be your body. 
    data: "body=" + $('#div').html(), 
    //msg is your PHP scripts' response 
    success: function(msg){ 
    alert("Data Saved: " + msg); 
    } 
}); 
0

或者你也可以試試這個:

 
$.post('ajax/sendEmail.php', 
    { body : $('#div').html() }, 
    function(msg) { 
     alert("Email was sent: " + msg); 
    });