开发者

htaccess in ajax fetching values

i m calling ajax function with htaccess ur开发者_StackOverflow中文版l rewriting.But i m not able to fetch value from server.My code is following..

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 code //

RewriteRule ^f/fetchname/(.*)/(.*)$ fetchname.php?fetchkey=$1&cityidval=$2 [NC]

When i m executing directly from url this is printing value.So there is no error in php page.

Is there any different way to fetch value in htaccess in ajax ?


Is there any different way to fetch value in htaccess in ajax ?

No. A request is a request, no matter whether it's made through Ajax or on the web browser. Note however that Ajax requests work on the same domain and protocol only! The calling page must also be on http://domain.in in your case.

The only exception comes to mind is a 302 redirect (instead of an internal one). That might give an Ajax request trouble. But your redirection is clearly an internal one, so I don't think that can be it.

Check the URL that gets queried in the Ajax call: Where do inputString and cityid come from? Are you 100% sure they are set? What happens if you output the javascript generated URL and try that in your browser?


I'm not used to working with JS so much, but somehow I do not understand how the code could work... should it not be more along this lines:

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

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

(I wanted to post it as a comment, but I can figure out how to get the code correct there)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜