I use the code below to handle ajax call erros. I would like to add the line number of that '$('body').append(...' line to be abble to echo it out. By line number, I mean the line number within my .js file. Wondering if that is possible to get the actual line number? Thank you in advance for your replies. Cheers. Marc
$.ajax({
type: "POST",
url: "myfile.php",
error: function(jqXHR, textStatus, errorThrown) {
$('body').append('aj.ERROR! [' + jqXHR.status + ' : ' + errorThrown + ']');
},
success: function(data) {
// somecode
}
});
The only way I know to expose the current line number is with the
window.onerrorevent handler, which has this signature:so in theory you could trigger a real error in your code (
throw?) and then do your append in the error handler, e.g:EDIT it works (in Chrome, at least…) – http://jsfiddle.net/alnitak/gLzY2/