Get Json data in jQuery

后端 未结 4 2027
温柔的废话
温柔的废话 2021-01-28 23:50

There is not a single clear example that explains how to pull json data as simple as possible. I have a valid json and I need to retrieve it with jQuery

my json output i

相关标签:
4条回答
  • 2021-01-29 00:18

    Try this one

    $.getJSON("http://www.pangeaadvisors.org/sep123/blog.cs.asp",{ PROCESS: "ViewBlog" }, function(json) {
                        for (var i = 0; i < json.length; i++) {
                            var title = json[i].Title;
                            $('<div class="news_title"></div>').html(title).appendTo('#news_wrap');
                        }
                });
    

    as redsquare answered you need for or $.each :)

    0 讨论(0)
  • 2021-01-29 00:21

    You'll have to look at how to make cross domain calls with ajax. Making the request like this will be denied by the browser.

    0 讨论(0)
  • 2021-01-29 00:22

    Try This

    var items = test.items;
    $.each(items,function(index,items){
        console.log(items.title); /// and items.date
    })
    
    0 讨论(0)
  • 2021-01-29 00:41

    UPDATE

    Its failing due to your url having 2 dots in the url

    Assuming the request is working (check firebug to see if the request goes out as a script tag & the response comes back) you will need to do

    $.each( json.items, function(){
    
       ...
    
    });
    

    or you can use normal js

    for (var i=0; i<json.items.length; i++) {
    
       ...
    
    }
    
    0 讨论(0)
提交回复
热议问题