我已经注意到调用Web服务返回json数据的许多代码示例,但实现通常涉及PHP等后端语言。有没有人知道所有的jQuery解决方案都很好?还有一个词,比如用id设置div标签,然后直接调用web服务,获取json数据并填充页面?根本没有PHP或其他后端服务器端代码。纯Jquery Web服务响应
某些东西没有意义。这完美地工作:
<script type="text/javascript">
jQuery(document).ready(function ($) {
$.ajax({
url: "http://api.wunderground.com/api/ac7e64a2f6e2d440/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType: "jsonp",
success: function (parsed_json) {
alert(parsed_json.location.city);
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
但它不应该?
你在找什么是关于jQuery的AJAX('.ajax()')功能的教程。尝试把这个在谷歌:jQuery的ajax例子 – Austin