My application, using an instance of Internet Explorer, is constantly checking the internet connection through Ajax. However, due to low bandwidth, Internet Explorer keeps crashing. What are some best practices that can be implemented to prevent this crashing and boost performance?
Below is the code I am currently using to check for the internet connection:
The explanation can be found at: -
where I obtained the jquery file.
(function ($) {
$.fn.checkNet = function (intCheckInterval, strCheckURL) {
if (typeof (intCheckInterval) === 'undefined') {
var intCheckInterval = 5
} if (typeof (strCheckURL) === 'undefined') {
var strCheckURL = window.location
} else if (strCheckURL.indexOf('http') === -1) {
var strCheckURL = 'http://' + strCheckURL
} intCheckInterval = intCheckInterval * 1000; function doRequest(strCheckURL) {
$.ajax({ url: strCheckURL, cache: false, success: function () {
if ($('#netWarn').length) {
$('#netWarn').fadeOut()
} $('.tempDisabled').removeAttr('disabled').removeClass('tempDisabled')
}, error: function () {
if (!$('#netWarn').length) {
$('body').prepend('<p id="netWarn">No internet connection detected, some features will be re-enabled when a connection is detected. </p>'); $('#netWarn').fadeIn()
}
}
})
} setInterval(function () {
doRequest(strCheckURL)
}, intCheckInterval)
}
})(jQuery);