2014-01-23 174 views
0

后阿贾克斯成功函数之后刷新主网页重定向页面,我想重定向页面,而无需刷新主页怎么没有Ajax成功功能

$.ajax({ 
    type: "POST", 
    url: "save_edit.php", 
    data: { id1: id, comment1: comment }, 
    success: function(data) { 
     $("#feedback").html(data); 
     $('#feedback').fadeIn('slow', function() { 
      $('#feedback').fadeOut(4000); 
      window.location = "comment.php"; 
     } 
}); 
+0

调用另一个AJAX功能,你的'success'函数内部 – user2936213

+0

对不起,我是新来的jQuery的东西!你可以解释吗! – user3226210

+0

请参阅下面的答案。 – user2936213

回答

2
$.ajax ({ 
    type: "POST", 
    url: "save_edit.php", 
    data: { id1: id, comment1: comment }, 

    success: function(data) { 
      $("#feedback").html(data); 
      $('#feedback').fadeIn('slow', function() { 
      $('#feedback').fadeOut(4000); 
      $.ajax ({ 
       type: "POST", 
       url: "comment.php", 
       data: { }, 
      }); 
      } 
}); 
1

你不能重定向到一个页面,而到comment.php令人耳目一新。您需要像这样将页面加载到当前页面;

$.ajax ({ 
    type: "POST", 
    url: "save_edit.php", 
    data: { id1: id, comment1: comment }, 

    success: function(data) { 
      $("#feedback").html(data); 
      $('#feedback').fadeIn('slow', function() { 
      $('#feedback').fadeOut(4000); 
      $("body").load("comment.php"); 
    } 
}); 

comment.php应该只包含正文部分

-1

不知道你想要什么,

但我认为你要加载comment.php与实际重新加载页面以及你可以改变

window.location = "comment.php"; 

$("html").load("comment.php"); // this will change the content of current page with comment.php content 
+0

谢谢Sanjeev ji,这对我有用。 – user3226210

+0

标记为正确 – sanjeev

1

使用这样的:

$.ajax ({ 
type: "POST", 
url: "save_edit.php", 
data: { id1: id, comment1: comment }, 

success: function(data) { 
     $("#feedback").html(data); 
     $('#feedback').fadeIn('slow', function() { 
     $('#feedback').fadeOut(4000); 
     $.ajax ({ 
      type: "POST", 
      url: "save_edit.php", 
     }); 
    } 
}); 
0

在成功事件使用

window.location.href="your page link";