我想用ajax发送wymeditor字段的值 代码如下所示;
$.ajax({
type: "POST",
url: "forms.php",
cache: false,
dataType: "html",
data: {action: 'add', parent: $('input.parent').val(), ntag: $('input.tag').val(), description: $('.wymeditor').html()},
});
我尝试了textarea的值 wym.val() / $(' .wymeditor')。html()
但是ajax没有发送任何参数
如何使用ajax发送textarea的值?
感谢。
答案 0 :(得分:2)
您需要在WYMeditor实例上调用xhtml()
方法,而不是在textarea本身上调用。假设你只有一个wymeditor,它是页面上的第一个:
$.ajax({
type: "POST",
url: "forms.php",
cache: false,
dataType: "html",
data: {
action: 'add',
parent: $('input.parent').val(),
ntag: $('input.tag').val(),
description: $.wymeditors(0).xhtml()
},
});
答案 1 :(得分:1)
尝试这个并将测试变量传递给ajax
var test = $('textarea#wymeditor').val();