I have the following code:
$.ajax({
type: 'GET',
url: 'edit_slides.php',
data: { user_id: user_id },
success: function() {
location.reload();
$('#messageContent').append('<p>success</p>');
}
});
What happens right now is that it appends and then reloads real quick so it loses the message.
Now, I could take out the reload and it will append but in order for my changes to take affect, the page needs to be reloaded.
Is there anything else I can do? I want to show a success message after reloading the page.
Thanks!
location.reload()will reload your page, which creates a new request to your server and the browser then loads the response. You could add a parameter to the query string for the message, e.g.Then in server side code, you could display the message if the parameter exists. In ASP.NET MVC, it would look like this:
If you don’t have server side scripting available, you can also parse the querystring with javascript.