jQuery ajax Error

$(function() {
$(document).ajaxError(function(event, xhr, status, thrown) {
console.log(thrown.message);
console.log(status.url);
console.log(xhr.status);
});
$.post("nonexist.html", function(data) {
console.log(data);
});
});
view raw ajaxError.js hosted with ❤ by GitHub

Get QueryString parameters

// Method 1
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Method 2
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
// Method 3
function QueryString(name) {
var AllVars = window.location.search.substring(1);
var Vars = AllVars.split("&");
for (i = 0; i < Vars.length; i++) {
var Var = Vars[i].split("=");
if (Var[0] == name) return decodeURIComponent(Var[1]);
}
return "";
}
view raw demo.js hosted with ❤ by GitHub