Требуется помошь Ошибка в JS
Помогите разобраться, в консоли выдается ошибка в function($) { Uncaught SyntaxError: Function statements require a function name
function($) {
var Utility = function() {
/**
* Local reference to network status
*
* @access private
* @var Boolean
*/
var networkStatus;
/**
* Check network status and manage application cache forced refresh
*
* @access public
* @return Boolean
*/
this.checkNetworkStatus = function() {
// Only check status and optional refresh if application cache and local storage are supported
if(!Modernizr.applicationcache || !Modernizr.localstorage || !rvzrOfflineCache) {
return false;
}
// Try to detect if are online/offline through a more reliable async request
$.ajax({
type: 'POST',
url: rvzrBaseURI + "index.php?option=com_responsivizer&task=dummycontroller.dummytask",
async: true,
success: function(data, textStatus, jqXHR){
// Store existing status
var previousStatus = localStorage.getItem('networkStatus');
networkStatus = true;
localStorage.setItem('networkStatus', networkStatus);
// If we was offline it's the moment to force a refresh to get now fresh cache resources
if(previousStatus === 'false') {
// Browser downloaded a new app cache.
window.location.reload();
}
},
error: function(jqXHR, textStatus, error){
networkStatus = false;
localStorage.setItem('networkStatus', networkStatus);
}
});
};
Ответы (1 шт):
Автор решения: Виталий Шебаниц
→ Ссылка
(function($) {
var Utility = function() {
/**
* Local reference to network status
*
* @access private
* @var Boolean
*/
var networkStatus;
/**
* Check network status and manage application cache forced refresh
*
* @access public
* @return Boolean
*/
this.checkNetworkStatus = function() {
// Only check status and optional refresh if application cache and local storage are supported
if(!Modernizr.applicationcache || !Modernizr.localstorage || !rvzrOfflineCache) {
return false;
}
// Try to detect if are online/offline through a more reliable async request
$.ajax({
type: 'POST',
url: rvzrBaseURI + "index.php?option=com_responsivizer&task=dummycontroller.dummytask",
async: true,
success: function(data, textStatus, jqXHR){
// Store existing status
var previousStatus = localStorage.getItem('networkStatus');
networkStatus = true;
localStorage.setItem('networkStatus', networkStatus);
// If we was offline it's the moment to force a refresh to get now fresh cache resources
if(previousStatus === 'false') {
// Browser downloaded a new app cache.
window.location.reload();
}
},
error: function(jqXHR, textStatus, error){
networkStatus = false;
localStorage.setItem('networkStatus', networkStatus);
}
});
}}})(jQuery); // мало скобок и дописать чутка
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>