由于jQuery的.load()doesn't工作.htaccess文件文件、工作、load、jQuery

2023-09-02 01:06:45 作者:不懂胜者为王-

我有一些对话窗口的按钮,提交按钮我称之为:

I have some dialog window with buttons, on the submit button I call this:

$("#delDiv").load("./protected/deleteUser.php?id="+id, function(data){
   alert(data);
});

但问题是,我的/保护目录的保护,.htaccess文件,在那里我简单地设置

Problem is, that my /protected directory is protected with .htaccess file, where I had simply set

这是所有拒绝

所以.load()命令doesn't可以访问该文件。有没有什么办法来访问文件的文件夹此功能?

so the .load() command doesn´t have access to that file. Is there any way to access that folder of file for this function?

推荐答案

该解决方案完全取决于框架/应用结构。总的来说,我会建议把 deleteUser.php 在公开的目录,因为一切都可以调用使用AJAX将可直接在浏览器中打开。事实上,你可以检查一些标题,以了解是否使用AJAX或不执行的请求,但他们都非常容易伪造。

The solution really depends on framework/application structure. In general I'd suggest to place deleteUser.php in publicly available directory, because everything you can call using AJAX will be available to opening directly in browser. In fact, you can check some headers in order to know if request is performed using AJAX or not, but they are very easy to fake.

另外,如果你使用的是什么框架,这是更好地利用其控制+动作系统,而不仅仅是一个独立的脚本。

Also, if you are using any framework, it is better to use its controller+action system, not just a standalone script.