我希望保持从Ajax到PHP Script的连接打开,以便我的CSV成功加载到数据库中。目前它在30秒时切断。以下是JavaScript。
我无法使用php来设置超时,因为RackSpace Load Balancer会切断30秒无效的脚本。
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form#bulk-upload').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
//console.log(percentVal, position, total);
},
success: function() {
var percentVal = '100%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
data = xhr.responseText;
var data = data.split("|");
var code = $.trim(data[0]);
var msg = $.trim(data[1]);
if( code == 1 ){
$("#ajax-msg").addClass("alert alert-success").html(msg);
} else {
$("#ajax-msg").addClass("alert alert-danger").html(msg);
}
return true;
}
});
})();