正如标题所说,我的 AJAX POST电话似乎无法找到其网址。这是因为在 .htaccess 文件中,我从网站的网址中删除了 .php 。
明显的错误
http://localhost/style-faq/includes/handlers/ajax/giveView 404 (Not Found)
的.htaccess
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://localhost/myWebsite/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/myWebsite/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
AJAX POST电话
function giveView(id){
$.post("includes/handlers/ajax/giveView.php", //already tried without .php
{
id: id
})
.done(function(response){
console.log(response);
})
}
有没有办法让 AJAX 调用正确的网址?或者是解决 .htaccess 代码的唯一解决方案,并在网址中看到 .php 过着充实的生活。