代码点火器和php形成ajax表单提交

时间:2013-09-02 17:28:00

标签: php jquery ajax

我正在尝试使用带有CI的jquery表单提交但我无法从php文件中获取返回值。

     $(document).ready(function($){
      $("#submit_btn").click(function(){

    var response = $.ajax({
        type: "POST",
        url: "send_email.php",
        data: $(commentForm).serialize()
    }).responseText;

.......
    here i want to get value return from PHP so that i can print that value
     like bellow
    .......
  $('#commentForm').html('<h5>Thanks</h5>'+here is result from php);
    return false;
});  

});

1 个答案:

答案 0 :(得分:1)

在ajax完成后显示消息

$.ajax({
    type: "POST",
    url: "send_email.php",
    data: $(commentForm).serialize()
}).done(function( msg ) {
   $('#commentForm').html('<h5>Thanks</h5>'+msg);
   return false;
});