English 中文(简体)
Cross domain AJAX requests using JQuery and YQL
原标题:

I need to use YQL (Yahoo Query Language) to perform a cross domain ajax request then bind the XML response into a JSON object and retrieve a value from the XML.

The link shows how this is done using the YQL service as a proxy for cross domain requests: http://ajaxian.com/archives/using-yql-as-a-proxy-for-cross-domain-ajax

For example I m trying to load the request below:

http://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%20%3D%20%22London%2C%20UK%2C%20UK%22&format=xml

After which I need to grab the WOEID value from the XML content returned. Is there a way to use similar code to query the XML data returned?

Thanks alot

最佳回答

What language are you calling from? If you re in PHP you can something like :

$url = "http://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%20%3D%20%22London%2C%20UK%2C%20UK%22&format=xml"
$data = file_get_contents($url);
$xml = simple_xml_load_file($data);
$woeid = $xml->query->results->place->woeid;

If you re in Javascript, I would recommend using "format=json" since JS handles that better.

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签