2010-10-21 78 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); 
    });