i am using proxy.php to call an api with jquery ajax. But it returns 301 error. In my local pc it seems to receive the data but not trigger the success function.
Here is the code:
var url = "http://api.yelp.com/business_review_search?term="+encodeURIComponent(term)+"&location="+zip+"&cc=US&ywsid="+ywsid+"&limit=10";
//alert(url);
jQuery.ajax({
url : template_directory+"/proxy/proxy.php",
type:'GET',
dataType: 'json',
data:{
proxy_url:url
},
success: searchResult,
error: showError
});
Also tried the get_json version of the code but same result? The proxy.php is now in a directory and calling the proxy like this:
url_to_the_proxy.php?proxy_url=url_to_call_api
I think the wordpress redirecting might cause this problem but don’t have experience how to fix it. Waiting for your reply. Thanks!
Sorry here is the page. Use the search function http://beta.citystir.com/entertainment/
Sounds like the path to your proxy is incorrect. The template_directory variable is called, but you need to use a URL, not a path. Be sure it’s the public facing path. If you’re using it locally you can usually call files like file: file:///Users, however that may not fly with jQuery. I’d suggest setting up a local apache server with WAMP or MAMP and trying the paths relative to your local URL. That should solve your issue.
Otherwise post more of your code and we can debug further.