Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Ajax请求返回404未找到_Jquery_Ajax_Opencart - Fatal编程技术网

Jquery Ajax请求返回404未找到

Jquery Ajax请求返回404未找到,jquery,ajax,opencart,Jquery,Ajax,Opencart,我一直在试图找到一个解决办法,但我似乎没有找到一个。当我尝试执行下面的ajax调用时,会得到404响应。该代码在本地主机上运行良好,但当我在远程服务器上上传更改时,会出现错误 $('#button-upload').on('click', function() { $('#form-upload').remove(); $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style

我一直在试图找到一个解决办法,但我似乎没有找到一个。当我尝试执行下面的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);
});
调试过程中的多次尝试使我的主机提供商出于安全原因阻止了我的IP地址。如何使ajax请求看起来是一种威胁?我的托管提供商采取的安全措施是否可能导致该错误?实际上,我可以从浏览器的网址访问URL,但不能从ajax调用访问URL

url: '/index.php?route=common/filemanager/upload&token=<?php echo $token; ?>&directory=<?php echo $directory; ?>',
url:'/index.php?route=common/filemanager/upload&token=&directory=',

您遇到了什么错误。?但是服务器上的文件也被命名为
index.php
,或者有一个名为
index.php
的文件?您可以发布wohle
警报的
错误消息吗?@Dileep Chris错误与
/admin/
目录中的
index.php
完全相同?您可能需要查看所提出请求的结构(即
https://example.com/admin/index.php?
)。您可能必须将存放项目的服务器上的文件夹名称放在
url
的开头。。所以可能是这样的:
“/FolderName/…
url: '/index.php?route=common/filemanager/upload&token=<?php echo $token; ?>&directory=<?php echo $directory; ?>',