通过AJAX将数据发送到PHP可以在localhost中运行,但不能在远程服务器上运行

时间:2015-11-27 14:15:47

标签: php ajax server localhost

我正在尝试托管文件Med ---> repo_display.php ---> repo_ajax.js --->返回repo_action_with_DB.php。这在我的本地主机上工作得很好但是一旦我将它发布到服务器它就不起作用。

当我提交repo_display.php表单以调用AJAX时,它会将我转移到服务器页面,并显示错误消息“error 403 - forbidden”

我尝试将js的权限更改为755-700并且除非AJAX有效,否则禁止访问repo_action_with_DB.php,尽管我也改变了他们的权限! 。我尝试访问页面而不提交表单显示同样的问题

  

403错误禁止未捕获的ReferenceError:prettyPrint不是   定义

repo_display.php

repo_display.php

repo_ajax.js

<html>
<head>
                <!-- report java script -->
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type='text/javascript' src='scripts/repo_ajax.js'> </script>
</head>
<body>
            <form action="" id="report">
    <legend style="margin-left:40px;">text : </legend>

    <p id="success" class="success"></p>
    <input id="radio1" name="radio" value="Publisher" type="radio" onclick="radioClicked1()" required>
    <input id="radio2" name="radio" value="Journal" type="radio" onclick="radioClicked2()" >
    <input   name="title1" type="text" required>                    
    <input  id="ISSN" name="ISSN" type="text" required>                       
    <input id="url" name="url" type="url" required><br>
    <input type="text" value="1" style="display:none;"/>
    <input  type ="submit" value="Save"/>
                            </form>
</body>
</html>

repo_action_with_DB.php

$(document).ready(function () {

    $("#send").click(function () {

        var type;
        if (document.getElementById('radio1').checked) {
            type = document.getElementById('radio1').value;
        }
        else if (document.getElementById('radio2').checked) {
            type = document.getElementById('radio2').value;
        }
        var title1 = document.getElementById('title1').value;
        var ISSN = document.getElementById('ISSN').value;
        var url = document.getElementById('url').value;


        if (type == 'Journal' && ISSN == '') {
            $("report")[0].checkValidity();
        }
        else if (type == '' || title1 == '' || url == '') {
            // alert("fill all required fields !");
            ("report")[0].checkValidity();
            if (type == 'Journal' && ISSN == '') {
                $("report")[0].checkValidity();
            }
        }
        else {
            var r = confirm
                    ("Are you sure to send this Report ?");
            if (r == true)
            {

                $.ajax({
                    type: "GET",
                    url: "repo_action_with_DB.php",
                    data: "radio=" + type + "&title1=" + title1 + "&ISSN=" + ISSN + "&url=" + url,
                    success: function (data) {
                        if (data == 1)
                        {
                            $("#success2").html("Done");

                        }
                        else if (data == 2)
                        {
                            $("#success").html("Your Report is exist already");

                        }
                        else
                        {
                            $("#success").html("Faild  ,please try again !");

                        }
                    }
                });
            }
        }
        return false;

    });

});
function radioClicked1() {
}
function radioClicked2() {
}

0 个答案:

没有答案