简体   繁体   English

错误403在同一域上使用jquery ajax调用进行调用时禁止

[英]Error 403 Forbidden when making post call with jquery ajax call on same domain

I have a webpage( mainmenu.php ) with a javascript function as script in the webpage. 我有一个网页( mainmenu.php ),网页上有一个javascript函数作为脚本。 The java script function name is : statusHistoryUpdate(status) java脚本函数名称是: statusHistoryUpdate(status)

This function does a ajax post call to a php file located on the same domain as my webpage. 此函数对与我的网页位于同一域的php文件进行ajax调用。 Here is the function code : 这是功能代码:

                    function statusHistoryUpdate(status)
                    {


                           var data = {
                                reg_no: selectedRegNo,
                                status: status,
                                progress_id : selectedProgress
                            };
                            data = $(this).serialize() + "&" + $.param(data);
                          //alert(data);
                          $.ajax({
                          type: "POST",
                          dataType: "json",
                          url: "../db/statusHistory.php", //Relative or absolute path to response.php file
                          data: data,
                          beforeSend: function(){

                            $('#loading').toggle();
                            //$("#submitbutton").html( "<button id='buttonsubmit' class='btn btn-primary btn-lg btn-block' type='submit' value='Register' disabled> <span class='spinner-border spinner-border-md'></span>Loading..</button>");
                          },
                          success: function(data) {

                              getData();
                          },
                          complete: function(){
                            //$('.ajax-loader').css("visibility", "hidden");
                            $('#loading').toggle();

                          },
                           error: function(xhr, status, error) {
                            alert(xhr.responseText);
                          }
                        });
                    }

You will see my url that I am posting to is url: "../db/statusHistory.php" 你会看到我发布的url: "../db/statusHistory.php"url: "../db/statusHistory.php"

This function is called using a button in mainmenu.php . 使用mainmenu.php中的按钮调用此函数。

<button id="'.$progress_id.'" type="button" class="btn btn-primary btn-sm btn-block" onclick="updateStatus('.$progress_id.',\''.$status.'\',\''.$reg_num.'\')">Update Status</button>

All of this worked up until this weekend something changed and now when this post call is executed it gives me an error 403 Forbidden , you dont have permission to access /db/statusHistory.php 所有这一切都工作到本周末发生了变化,现在当这个帖子被执行时它给了我一个错误403 Forbidden ,你没有权限访问/db/statusHistory.php

This is the alert in the error: part in the ajax call : 这是错误中的警报:ajax调用中的一部分:

在此输入图像描述

I do not know what is causing this, I have checked permissions, I have created a new php file to post to but it still gives me the same error. 我不知道是什么导致这个,我已经检查了权限,我已经创建了一个新的php文件发布到但它仍然给了我同样的错误。

I am hosting on a shared hosting server,using php, jquery/3.4.0. 我在共享托管服务器上托管,使用php,jquery / 3.4.0。 I have only access to the shared hosting panel "CPanel" not the linux server. 我只能访问共享主机面板“CPanel”而不是linux服务器。

Here is screen shots of my hosting directory and permissions. 这是我的托管目录和权限的屏幕截图。 My mainmenu.php is in directory phplogin , mainmenu.php makes a post call to statusHistory.php and it is in the directory db mainmenu.php在目录phplogin,mainmenu.php使得后调用statusHistory.php,它是在目录数据库

Public html directory : 公共html目录: 在此输入图像描述

phplogin Directory : phplogin目录: 在此输入图像描述

db Directory : 数据库目录: 在此输入图像描述

What should I be doing differently for my post call to work? 我的上班后工作应该做些什么? As I said it did work for about a month and just stopped... 正如我所说它确实工作了大约一个月而且刚刚停止......

Any help would be appreciated. 任何帮助,将不胜感激。

More Screenshots chrome developer tools : 更多截图chrome开发者工具:

Network tab : 网络标签: 在此输入图像描述

在此输入图像描述 在此输入图像描述 在此输入图像描述

如果之前有效,您应该检查您的.htaccess文件,该文件位于您网站的根目录中。

I have been struggling for 2 days now trying to figure out what is the problem, it turns out the problem was mod_security I disabled mod_security for my domain and my problem was resolved, I will contact my hosting company and ask them to properly do the setup. 我已经苦苦挣扎了两天,现在试图找出问题所在,结果问题是mod_security我为我的域禁用了mod_security并且问题解决了,我会联系我的托管公司并要求他们正确地进行设置。

Not sure why it just started happening. 不知道为什么它刚刚开始发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM