Answer the question
In order to leave comments, you need to log in
jquery getScript from remote host, error handling?
Hey habr! I am writing a widget for windows 7. The script loads data from a remote host using the getScript method and processes it. Everything is fine, but I can't figure out how to handle errors (for example, there is no Internet connection on the computer). Now the code looks like this:
function load_script(num){<br/>
var jqxhr = $.ajax({ url: 'http://nnnnn.ru/getdata.php', dataType: 'script' })<br/>
.success(function() {<br/>
$('#content').html(html);<br/>
})<br/>
.error(function() {<br/>
html = 'Ошибка установки соединения';<br/>
$('#content').html(html);<br/>
});<br/>
}
Answer the question
In order to leave comments, you need to log in
I'm not sure about my answer because I don't really understand what your problem is,
but when I work with jquery I always ask for a specific kind of response (dataType). And then, when I don’t get a good answer (usually I only pull json through jquery), it will cause me an error.
Maybe not relevant already, but suddenly someone is also looking for ..
$.ajax({
// ... //
error: function (request, status, error) {
// request.responseText - эту переменную пощупайте
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question