【发布时间】:2014-04-12 00:18:50
【问题描述】:
我创建了基本项目并使用 htaccess 重写 url 和 jquery ajax
.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1
gallery.php:
<script type="text/javascript">
window.onload = function() {
$.ajax({
type: "POST",
url: "/test1/controller.php",
data: {brand:"<?php echo $id;?>"},
dataType: "json",
success: function (data) {
alert(data.response)
}
});
}
controller.php:
$brand=$_REQUEST['brand'];
$arr = array ('response'=>$brand.'___jason','comment'=>'test comment here');
echo json_encode($arr);
但是当在浏览器的地址栏中写网址时:
http://localhost/test1/gallery/gucci
jquery ajax 不工作,但写入时:
http://localhost/test1/gallery
jquery ajax 运行良好。
我必须使用 url 结尾 (gucci) 作为 id ,但是当我写它时,jquery 不起作用
【问题讨论】: