2012-07-11 50 views
0

点击提交后,我有一个表单更新更多的内容。这部分的所有元素都已经在DOM中。我遇到$ .post的问题,因为它是异步的,并尝试切换到$ .ajax,但现在当我单击表单的这部分单击提交时,什么也没有发生。

不工作:

$.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); 
     } 
     ); 

我试着用.fail看看,如果我得到一个错误,但好像没有什么改变,它只是停止。

感谢您的帮助。

+1

? – Petah 2012-07-11 05:41:40

+0

你需要'成功'函数来代替'done' – Jashwant 2012-07-11 05:43:56

+0

@Jashwant依赖于他的jQuery版本(1.7他应该使用'.done')。 – 2012-07-11 05:46:25

回答

1
$.ajax({ 
      type: 'POST', 
      url: 'functions/flow.php', 
      data: { 
       step: 3, 
       id: question_id 
      }, 
      async: false, 
      success:function(data){ 
       $('#fourth_step .form').append(data); 

      } 
}); 
什么版本的jQuery您使用的是
0
$.ajax({ 
    type: 'POST', 
    url: 'functions/flow.php', 
    data: "step="+3+"&id="+question_id, 
    async: false 
    success: function(data) { 
    $('#fourth_step .form').append(data); 
    } 
}); 
0
$.ajax({ 
    type: 'POST', 
    url: 'functions/flow.php', 
    data: '{"step":3,"id":'+question_id+'}', 
    async: false 
    success: function(data) { 
    $('#fourth_step .form').append(data); 
    } 
}); 
+0

Upvoting您的文章帐户的系列downvotes,本页面上的所有解决方案将工作。 – Ohgodwhy 2012-07-11 05:59:03