Jquery 将$.post更改为$.ajax不起作用?
我有一个表单,单击“提交”后会更新更多内容。此部件的所有元素都已在DOM中。我在使用$.post时遇到了问题,因为它是异步的,并尝试切换到$.ajax,但现在当我在表单的这一部分单击submit时,什么也没有发生 不工作:Jquery 将$.post更改为$.ajax不起作用?,jquery,ajax,post,Jquery,Ajax,Post,我有一个表单,单击“提交”后会更新更多内容。此部件的所有元素都已在DOM中。我在使用$.post时遇到了问题,因为它是异步的,并尝试切换到$.ajax,但现在当我在表单的这一部分单击submit时,什么也没有发生 不工作: $.ajax({ type: 'POST', url: 'functions/flow.php', data: { step: 3, id
$.ajax({
type: 'POST',
url: 'functions/flow.php',
data: {
step: 3,
id: question_id
},
async: false
}).done(function(data) {
$('#fourth_step .form').append(data);
});
这项工作:
$.post("functions/flow.php", {
step: 3,
id: question_id
}, function(data) {
$('#fourth_step .form').append(data);
}
);
我试过使用。看不出是否有错误,但似乎什么都没有发生,只是停止了
谢谢你的帮助。你用的是什么jQuery版本?你需要一个
成功
函数来代替'done'@Jashwant,这取决于他的jQuery版本(1.7他应该用.done
)。我甚至没有想过这个版本,但现在我知道:)我用1.4.4向上投票来解释连续的向下投票,此页面上的所有解决方案都将起作用。
$.ajax({
type: 'POST',
url: 'functions/flow.php',
data: "step="+3+"&id="+question_id,
async: false
success: function(data) {
$('#fourth_step .form').append(data);
}
});
$.ajax({
type: 'POST',
url: 'functions/flow.php',
data: '{"step":3,"id":'+question_id+'}',
async: false
success: function(data) {
$('#fourth_step .form').append(data);
}
});
$.ajax({
type: 'POST',
url: 'functions/flow.php',
data: {
step: 3,
id: question_id
},
async: false,
success:function(data){
$('#fourth_step .form').append(data);
}
});