В настоящее время я использую jQuery Idle Timeout в моей системе Laravel 5.2.
Он работает отлично на моем локальном компьютере (MAMP Pro), но когда я загрузил его на сервер разработки, то AJAX получить запрос дает «Aborted» Ошибка: jQuery AJAX прерван в Laravel 5.2 с использованием jQuery idle timeout
Что, кажется, проблема?
Laravel Маршруты Код:
Route::get('/keepalive', function() {
return view('keepalive');
});
JQuery Код:
$(function() {
// dialog is in the main layout after login = admin.blade.php
$("#dialog_session_timeout").dialog({
autoOpen: false,
modal: true,
width: 400,
height: 200,
closeOnEscape: false,
draggable: false,
resizable: false,
buttons: {
'Yes, Keep Working': function() {
$(this).dialog('close');
},
'No, Logoff': function() {
// fire whatever the configured onTimeout callback is.
// using .call(this) keeps the default behavior of "this" being the warning
// element (the dialog in this case) inside the callback.
$.idleTimeout.options.onTimeout.call(this);
}
}
});
// cache a reference to the countdown element so we don't have to query the DOM for it on each ping.
var $countdown = $("#dialog-countdown");
var _token = $('meta[name="csrf-token"]').attr('content');
var data = {
'_token': _token
};
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
// start the idle timer plugin
$.idleTimeout('#dialog_session_timeout', 'div.ui-dialog-buttonpane button:first', {
//idleAfter: 5, // in seconds
idleAfter: 7170, // 2 hours minus 30 seconds. 2 hours in the config/sessions.php
pollingInterval: 10,
//keepAliveURL: base_url + '/keepalive.php',
keepAliveURL: base_url + '/keepalive',
data: data,
serverResponseEquals: 'OK',
onTimeout: function() {
window.location = "logout";
},
onIdle: function() {
$(this).dialog("open");
},
onCountdown: function(counter) {
$countdown.html(counter); // update the counter
}
});
Какова ценность 'base_url'? – srph
@srph IP-адрес с портом 8080, как 123.456.789.222:8080 – marknt15
Можете ли вы попробовать установить 'AJAXTimeout' как минимум на' 1000'? Я знаю, что это звучит глупо, потому что 'AJAXTimeout' по умолчанию -' 250' (в то время как ваши запросы находятся под '250'). Но давайте просто попробуем :) – srph