0
我想用jquery抓取div的內容並將其傳遞給通過電子郵件發送的php腳本。所以我需要使用$('#div')。html()並將其發送到$ _POST ['']值。有任何想法嗎?jquery選擇要發佈的值
我想用jquery抓取div的內容並將其傳遞給通過電子郵件發送的php腳本。所以我需要使用$('#div')。html()並將其發送到$ _POST ['']值。有任何想法嗎?jquery選擇要發佈的值
(從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);
}
});
或者你也可以試試這個:
$.post('ajax/sendEmail.php', { body : $('#div').html() }, function(msg) { alert("Email was sent: " + msg); });