[英]data is not fetching by using ajax with mod_rewrite
请耐心我,我不知道如何解释我的问题,我是新的mod re_writing我有两页
index.php有一个搜索字段和一个div,其中数据将被提取。搜索字段使用Ajax从数据库中提供即时结果。
如
搜索字段即时结果
当我在index.php上它给我正确的结果,在这里我使用一个改写规则转
http://localhost/user_profiles/index?u=tol
成
http://localhost/user_profiles/index/u/tol
并给我个人资料视图
这两个网址都给了我正确的结果,但问题是当我开启时的ajax
http://localhost/user_profiles/index?u=tol
ajax工作得很好,给我正确的结果,但是当我在
http://localhost/user_profiles/index/u/tol
它给出了奇怪的结果
我不知道如何修复它是我的re_write规则
Options +FollowSymLinks
RewriteEngine on
RewriteRule u/(.*) index.php?u=$1 [L,QSA]
index.php的另一个规则就是索引
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
我的ajax查询是
maq.open('GET','search?q='+userVal,true);
请帮我 。
请记住,文件引用在JavaScript中是相对的。
当您进入重写页面时,您需要使用以下内容更新要search
的链接:
maq.open('GET', '../../search?q='+userVal, true);
本质上,我们所在的虚拟目录中有两个目录(即从user_profiles/index/u/tol/search
到user_profiles/index/search
)。
或者,您可以使用前导/
相对于根指定它,例如:
maq.open('GET', '/user_profiles/index/search?q='+userVal, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.