0
我一直在试图找到一个解决方案,但我似乎找不到一个。我尝试执行以下ajax调用时收到404响应。代码工作在本地主机上正常,但当我上传边远服务器上的变化,我得到的错误Ajax请求返回404找不到
$('#button-upload').on('click', function() {
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" value="" /></form>');
$('#form-upload input[name=\'file\']').trigger('click');
if (typeof timer != 'undefined') {
clearInterval(timer);
}
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
$.ajax({
url: 'index.php?route=common/filemanager/upload&token=<?php echo $token; ?>&directory=<?php echo $directory; ?>',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
$('#button-upload').prop('disabled', true);
},
complete: function() {
$('#button-upload i').replaceWith('<i class="fa fa-upload"></i>');
$('#button-upload').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});
控制台错误是
POST https://example.com/admin/index.php? route=common/filemanager/upload&token=jyHPuiTt1DjdemKjNWUbeZqOtHHj4Dxw 404 (Not Found)
多次尝试在调试时让我的托管服务提供商阻止我IP地址出于安全原因。如何使ajax请求成为威胁,并且我的托管提供商采取的安全措施是否会导致错误?其实我可以从我的浏览器的网址从Ajax调用
你得到什么错误? – Dileep
但服务器上的文件也被命名为'index.php'或者有一个名为'index.php'的文件?你可以发布“提醒”错误消息吗? – Chris
@Dileep Chris错误与上述完全相同 – facilitator