POST AJAX请求被拒绝

问题描述 投票:0回答:1

当我试图发送一个Ajax请求时,在浏览器控制台中出现了这样的错误(在所有的浏览器下

如果有人能帮助我,我会很高兴:)

我不明白代码中的错误在哪里?

如果有人知道如何修复它

js脚本代码。

$('#register').submit(function(e) {
    e.preventDefault();
    var findme = "Error";
    if(isEmpty($('#year').val()) || isEmpty($('#day').val()) || isEmpty($('#month').val())){
        swal({
            title: 'uhm...',
            text: site_lang[182].text,
            type: "error"
        }, function(t) { 
        })  
    return false;   
    }
    $.ajax({
            data:  $(this).serialize(),
            url:   request_source()+'/user.php',
            type:  'post',
            beforeSend: function () {
                $("#create-acc").html(site_lang[275].text);
                $('#error').hide();
            },          
            success:  function (response) {     
                if ( response.indexOf(findme) > -1 ) {
                    response = response.replace('Error','');
                    swal({
                        title: 'uhm...',
                        text: response,
                        type: "error"
                    }, function(t) { 
                    })
                    $("#create-acc").html(site_lang[8].text);
                } else {
                     window.location=site_config['site_url']+'meet';
                }
            }
    });                 
});

错误日志。

[Error] Cross-origin redirection to http://example.com/requests/user.php denied by Cross-Origin Resource Sharing policy: Origin http://example.com/ is not allowed by Access-Control-Allow-Origin.
[Error] XMLHttpRequest cannot load http://example.com/requests/user.php due to access control checks.
[Error] Failed to load resource: Cross-origin redirection to http://example.com/requests/user.php denied by Cross-Origin Resource Sharing policy: Origin http://example.com/ is not allowed by Access-Control-Allow-Origin. (user.php, line 0)
php ajax post cors
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.