【问题标题】:json data not load after load page [duplicate]加载页面后未加载json数据[重复]
【发布时间】:2015-07-18 17:26:44
【问题描述】:

我已经在 javascript 中读取了 json 数据。但 json 数据不显示第一次页面加载,刷新页面后加载。请解决我的问题。 这是我的代码:

$(document).ready(function () {
  $.ajax({
            url:"http://192.168.0.105/stratagic-json/project_json.php",
            type:"GET",
            dataType:"json",
            beforeSend: function(){
            success:function(jsonData){
     var projctList = '';

  for (var i = 0; i < jsonData.length; i++) {
      projctList += ' <li><div class="proj-details-wrap"> <img src="images/project-img.jpg" /><div class="proj-badge">Upcoming Projects</div><div class="proj-name">'+ jsonData[i].name +'<span>'+ jsonData[i].location +'</span> </div><div class="proj-status">'+ jsonData[i].percentage +'% <span>completed</span> </div></div><div class="container proj-desc">'+ jsonData[i].description +' </div> </li>';
     }
          $("#projctLists").html(projctList);

     }
     }); 
});

【问题讨论】:

    标签: javascript html json


    【解决方案1】:

    A quick Google search 会告诉你如何使用JSON.parse

    console.log(JSON.parse('[ { "id": "1", "title": "Mr", "name": "neeraj", "mobile": "9076123344", "emailID": "neerajt43@gmail.com", "projname": "Aryan Heights", "subproj": "A Wing", "unit": "Pent House", "budget": "25 to 30 Lacs", "comments": "This is test Comment" }, { "id": "3", "title": "Mr", "name": "neeraj", "mobile": "9076554744", "emailID": "neerajt43@gmail.com", "projname": "Aryan Heights", "subproj": "A Wing", "unit": "Row House", "budget": "25 to 30 Lacs", "comments": "This is test" } ]'));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-02
      • 1970-01-01
      • 2013-03-28
      相关资源
      最近更新 更多