我一直在检查summernote API,并且有我的代码
<form id="mail">
<input type="text" id="email">
<textarea id="summernote"></textarea>
<input type="submit">
</form>
$('#summernote').summernote({
placeholder: 'your Message',
tabsize: 2,
height: 300
});
$('document').ready(function() {
var messageData = $('#summernote').summernote('code');
var email = $('#email').val();
$(function() {
$('#mail').submit(function(event) {
event.preventDefault();
$.ajax({
url: 'sendmail.php',
type: 'post',
data: {
'send_mail': 1,
'to': email,
'message': messageData,
},
success: function(response) {
if (response == 'success') {
//my success response
} else if (response == 'error') {
//my error response
}
}
});
});
});
});
我的问题是邮件已成功发送,但是我没有得到该文本区域的值,只是一封空电子邮件.请帮忙.
注意:我正在使用phpMailer发送电子邮件.
解决方法:
更改代码如下:
>在ready函数中初始化“ summernote”.
>在邮件提交事件中获取夏季笔记的值
代码如下:
$('document').ready(function(){
$('#summernote').summernote({
placeholder: 'your Message',
tabsize: 2,
height: 300
});
$(function(){
$('#mail').submit(function(event){
var messageData = $('#summernote').summernote('code');
var email = $('#email').val();
event.preventDefault();
$.ajax({
url: 'sendmail.php',
type: 'post',
data: {
'send_mail' : 1,
'to' : email,
'message' : messageData,
},
success: function(response){
if(response == 'success'){
//my success response
} else if (response == 'error'){
//my error response
}
}
});
});
});
});