我有这两个按钮
<div id="rating-votes">
<button class="btn like">Like</button>
<span class="likes">0</span>
<button class="btn dislike">Dislike</button>
<span class="dislikes">0</span>
</div>
我正在尝试使用ajax调用传递数据,但它没有将数据发送到php
其脚本
$('#rating-votes').likeDislike({
reverseMode: true,
disabledClass: 'disable',
click: function (value, l, d, event) {
var likes = $(this.element).find('.likes');
var dislikes = $(this.element).find('.dislikes');
$.ajax({
url: '',
type: 'POST',
data: 'likes=' + likes + '&dislikes=' + dislikes,
success: function (data) {
likes.text(parseInt(likes.text()) + l);
dislikes.text(parseInt(dislikes.text()) + d);
}
});
}
});
任何人都可以做一些修正
答案 0 :(得分:0)
数据格式取决于您要传递的类型:
表单数据
var form = new FormData();
form.append("a", "b");
$.ajax({....
"data": form
})
X WWW的形状进行urlencode
$.ajax({....
"data": { "a": "b" }
})
原始json身体
$.ajax({...
"data": JSON.parse({ "a": "b" })
})