Reputation: 1
After ajax success function, I want to redirect page to comment.php without refreshing main page
$.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";
}
});
Upvotes: 0
Views: 10430
Reputation: 2365
On success event use
window.location.href="your page link";
Upvotes: 0
Reputation: 1011
Use like this:
$.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",
});
}
});
Upvotes: 1
Reputation: 15550
You can not redirect to a page without refreshing. You need to load page into your current page like this;
$.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
should only contain body part
Upvotes: 1
Reputation: 3334
$.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: { },
});
}
});
Upvotes: 2