当我按下一个按钮时,我执行一个返回数据的 ajax 发布。该 ajax 发布更新数据并返回一个数字来告诉我该按钮是否应该突出显示。我的问题是,我希望 ajax post 回调函数返回数字和更新的信息。这在 ajax 文件上很容易做到,但我不确定如何在回调函数上做到这一点。下面是一个简单的例子。
$.post(ajax_file,
{
primary_id: primary_id
},
function (data){
//ajax file calls back the number 1 or the number 0. But I want to return more
//than just that. Maybe an array would work?
if (data == 1)
{
$(the_button).addClass('highlighted');
}
else if (data == 0)
{
$(the_button).removeClass();
}
});