0

我正在使用 mvc3,razor.The 链接(api.eventful.com/json/events/search?app_key= * ** * ** &location=San+Diego)工作正常,我从链接中获取 json,当我应用我的 app_key。但在这里我什么也没得到。我是 jquery 的新手。专家请帮帮我?这是我的查看代码。

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.9.0.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(window).load(function () {      
        $.getJSON('http://api.eventful.com/json/events/search?app_key=**************&location=San+Diego', function (data) {
            $.each(data.events.event, function (i, x) {                   
                $('<h1/>').text(x.postal_code).appendTo("#photographs")    
            });    
        });    
    });    
    </script>
    <div id="photographs"></div>

下面是一个json的示例,它不完全

{"last_item":null,"total_items":"6075","first_item":null,"page_number":"1","page_size":"10","page_items":null,"search_time":"0.032" ,"page_count":"608","events":{"event":[{"watching_count":null,"calendar_count":null,"comment_count":null,"region_abbr":"CA","postal_code": "92123","going_count":null,"all_day":"0","纬度":"32.8315208","

4

1 回答 1

0

最后通过大量实验,我得到了它。

通过改变

$.getJSON(' http://api.eventful.com/json/events/search?app_key= * ** * ** &location=San+Diego', 函数(数据)

进入

$.getJSON(' http://api.eventful.com/json/events/search?app_key= * ** * ** &location=San+Diego&callback', 函数(数据)

只需要添加一个回调..

于 2013-10-29T10:38:52.247 回答