Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ajax中的htaccess获取值_Php - Fatal编程技术网

Php ajax中的htaccess获取值

Php ajax中的htaccess获取值,php,Php,我正在使用htaccess url重写调用ajax函数。但我无法从服务器获取值。我的代码如下 function lookup(val1,val2) { //some code here //// if (xmlhttp.readyState==4){ alert(xmlhttp.responseText); // but i m not getting values } var str=inputString+'/'

我正在使用htaccess url重写调用ajax函数。但我无法从服务器获取值。我的代码如下

function lookup(val1,val2) {

        //some code here ////

       if (xmlhttp.readyState==4){
              alert(xmlhttp.responseText); // but i m not getting values
       } 

var str=inputString+'/'+cityid;
xmlhttp.open("GET","http://www.mydomain.in/f/fetchname/"+str,true);
xmlhttp.send();
}
////htaccess代码//

RewriteRule ^f/fetchname/(.*)/(.*)$ fetchname.php?fetchkey=$1&cityidval=$2 [NC]
当我直接从url执行时,这是打印值。所以php页面中没有错误

在ajax中,htaccess中是否有其他获取值的方法

在ajax中,htaccess中是否有其他获取值的方法

不,请求就是请求,不管它是通过Ajax还是在web浏览器上发出的。但是请注意,Ajax请求仅在相同的域和协议上工作!呼叫页面也必须在
http://domain.in
在您的情况下

我想到的唯一例外是
302
重定向(而不是内部重定向)。这可能会给Ajax请求带来麻烦。但你的重定向显然是一个内部的,所以我认为这不可能


检查Ajax调用中查询到的URL:
inputString
cityid
来自哪里?您是否100%确定它们已设置?如果您输出javascript生成的URL并在浏览器中尝试,会发生什么情况?

我不太习惯使用JS,但不知怎的,我不明白代码是如何工作的。。。如果不是这样的话:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onreadystatechange = checkData;
xmlhttp.send();

if (xmlhttp.readyState==4){
          alert(xmlhttp.responseText);
} 

(我想将其作为评论发布,但我可以找出如何在那里更正代码)

Pekka,感谢您的编辑,现在更容易阅读:)是的,当我从url运行这些值时,我得到了值。@Ajay和您执行请求的页面也在
mydomain.in
中?$Search=mysql\u real\u escape\u string($\u request['fetchkey')); $cityidloc=$_请求['cityidval'];我从这些请求中获取perfetct值。因为当我运行这个查询()时,我得到$Search='dwa'和cityidloc='17',并且我的查询执行得很好。我在那里回显值,并尝试通过警报(xmlhttp.responseText)从ajax服务器获取文本输出;当我直接执行时,这在浏览器上回响良好,但通过ajax我无法获取值。我的htaccess有什么问题吗?@ajay是您在同一个域
mydomain上发出请求的页面。在
中,您从xml文件中获取值,但我直接从数据库中获取值并在页面上回显这些值。因此ajax将以xml格式输入这些回显值,这将由用户访问xmlhttp.responseText。我认为ajax不理解返回的url,因为url重写mi,对吗?url是不相关的。我想在这里指出的是,您首先阅读响应,然后执行AJAX调用。按照我的逻辑,这是行不通的。如果调用函数2x,它可能会工作