jquery .load() doesn´t work due to the .htaccess f

2019-09-09 07:42发布

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);
});

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

deny from all

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

1条回答
倾城 Initia
2楼-- · 2019-09-09 08:25

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.

查看更多
登录 后发表回答