Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect with message after success ajax call

Tags:

jquery

ajax

How to make it when function success redirect user to index page to show message on the page that deletion was successful? So far I was able only to redirect user

$.ajax({
   type: 'get',
   url: 'lessonDel.php', 
   data: 'ajax=1&delete=' + upload_id,

   success: function()
   {
        window.location.href = 'index.php';
        //alert('You successfully deleted this Lesson!  Status = ' + xhr.status); 
   }             
});         

1 Answers

change window.location.href = 'index.php#lessondelete';

in your index page :

$(function(){
var hash = window.location.hash
if(hash == "#lessondelete") {
  alert('You successfully deleted this Lesson!'); 
//$('body').prepend('<p>You successfully deleted this Lesson</p>')
}
});
like image 119
madalinivascu Avatar answered Dec 23 '25 23:12

madalinivascu