I have a few menu items on the left side of the screen, each opens a new page on the site. On one of the pages there is an async ajax call to python that successfully returns a bunch of data.
However, when I open this page and quickly click on another menu item to open another page without waiting for the ajax request to finish, I receive an [Object object] error.
postData = {"userid":userid, "current":dict_current, "step":dict_step};
$.ajax({
url: "/cgi-bin/get_dictionary.py",
type: "post",
datatype:"json",
async : true,
data: {postData},
success: function(response){
//parse json
var json = $.parseJSON(response);
}
})
.fail(function(err) {
alert("error" + err); //[Object object]
});
So I guess, I should somehow abort the request when I open a new page, but how do I access that request?
What is the best thing to do here?