我一直在处理的快速问题,但似乎无法解决。
我有一个 ajax 调用,但它没有从 php 文件中得到响应,它似乎正在加载 404。
地址栏中的 url 是“mydomain.com/checkcity/”
带有ajax的文件的位置是“/php/advert/script.php”
要调用的php文件的位置是“/php/advert/available.php”
我通过使用 htaccess 来使用虚拟 url。
这是我的ajax调用:
$.ajax({
type: "POST",
url: "/available.php",
data: "city="+city,
success: function(response){
alert(response);
}
});
这是我的 htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我注意到的一件事是,当我在地址栏中搜索 url 时,它会加载 php 文件,而不是使用 ajax 调用。
我目前在 Apache 2.2 localhost 上运行它
感谢您的任何建议。