我执行使用jQuery一个简单的AJAX()请求(谷歌托管1.7.1 jquery.min.js code)
I am performing a simple AJAX() request using Jquery (Google hosted 1.7.1 jquery.min.js code)
在code是pretty的简单:
The code is pretty simple:
$.ajax({
type: "POST",
url: "../inc/ajax_msgread_sendPM.php",
data: "fromuserid=<?php echo $fromuserid; ?>&pmSubject=<?php echo urlencode($pmSubject); ?>&pmBody=" + pmReply,
success: function(data){
$("#showSuccess").show("fast");
$("#resultResponse").html(data);
}
});
mod_rewrite的的.htaccess这个文件是:
The mod_rewrite .htaccess for this document is:
RewriteRule ^messages/read/([^/]+)/([^/]+)/?$ /msgread.php?usernam=$1&keynode=$2 [QSA,L]
当我查看$ resultResponse出于某种原因,阿贾克斯一直希望把$ 1插入'增量',所以任何不相关(或相关)MySQL查询中使用 $ _ GET [usernam]
从URL最后返回INC
When I view the $resultResponse for some reason the Ajax keeps wanting to turn $1 into 'inc' so any unrelated (or related) mySQL queries using $_GET["usernam"]
from the URL ends up returning 'inc'
这是怎么回事?还有就是我的脚本和mod_rewrite的没有关系。有名为usernam或1上的脚本不变量(或在网站上的任何地方)。
Why is this happening? There is no relation between my script and the mod_rewrite. There are no variables named "usernam" or "1" on the script (or anywhere on the site).
萤火虫不提供任何帮助。
Firebug gives no help.
高见?
更新:
我看到问题的根源。在阿贾克斯jQuery的code到来:
I see where the problem is coming from.. in the ajax jquery code:
网址:../ INC / ajax_msgread_sendPM.php
url: "../inc/ajax_msgread_sendPM.php",
在公司不断得到设置,因为它的基于位置的mod_rewrite规则的用户名。我需要以某种方式从mod_rewrite的排除这个......只是不知道如何解决这个问题
the "inc" keeps getting set as the username because of its location based on the mod_rewrite rules... I need to somehow exclude this from mod_rewrite... just not sure how to solve this problem
推荐答案
只要当前网址为您的网页
As long as current url for your page is
www.domain.com/messages/read/username/NQ
和你使用相对路径 - 它被改写成
and you use relative path - it is being rewritten to
www.domain.com/messages/read/username/inc/ajax_msgread_sendPM.php
这绝对不是你想要的。最简单的解决办法是在AJAX端点URL更改为:
which is definitely not what you want. The simplest solution would be to change the ajax endpoint url to:
url: "/inc/ajax_msgread_sendPM.php",
相关推荐
最新文章