I have in my homepage an AJAX function. If the AJAX method triggers an error, it displays error text on the screen.
$.getJSON(url,
{},
function (data) {
......
}
).error() {
ShowError();
}
);
Sometime the user clicks on a link to another page while the function tries to get the data, and then the function stops and displays the error text until the next page is loaded.
How can I handle it so it won’t show the error text in this case where the user clicked on a different link?
You could bind a ‘click‘ event to the a tag which sets a global flag. Then only show the error message if the flag is not set.