jsonp AND ajax

前端之家收集整理的这篇文章主要介绍了jsonp AND ajax前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!-- lang: js -->

$(document).ready(function() {
   
   var now_date = new Date();
   var now_date_today = new Date("yy,mm,dd");  
   var now_time_obj =  document.getElementById("now_time");
   now_time_obj.textContent = now_date_today;
   var date_now = document.getElementsByClassName("op_weather4_twoicon_date")
   date_now.item(0).innerHTML = now_date;

   var total_left_div_class = document.getElementsByClassName("op_weather4_twoicon_temp");

    $.ajax({
      url: "http://10.255.32.250/total_left",data: '',dataType: 'jsonp',// jsonpCallback:'callback',//jsonpCallback:'',success: function(result) {
          var total_left = result[0]["total_left"];
          var total_obj = total_left_div_class.item(0);
          console.log("hello");
          total_obj.innerHTML = total_left; 
      }
    });

   
 
    $.ajax({
      url: "http://10.255.32.250/recent_done_seven_days",//jsonpCallback:'callback',success: function(result_get) {
          
          var url_range = result_get.url_range;
          url_range.sort()
          var result = result_get.result;
          var div_class_date_obj = document.getElementsByClassName("op_weather4_twoicon_date");
          var div_class_date_href = document.getElementsByClassName("op_weather4_twoicon_day OP_LOG_LINK");
          var count = 0;
          var day_arr = new Array;
          for ( var i in result) {
               day_arr.push(i)
          }
          day_arr.sort();

          for (var i in day_arr){
             var i  = day_arr[i] 
             count +=1; 
             var date_obj = div_class_date_obj.item(count);
                 date_obj.innerHTML = i;
             var total_src_obj = total_left_div_class.item(count);
               total_src_obj.innerHTML = "来源 <br>" + result[i];
             var day_href_obj = div_class_date_href.item(count-1);
                 var url_links = "http://10.255.32.250/daily_comming?"+ url_range[count-1]
                 day_href_obj.setAttribute("href",url_links);   
           }  
      }
    });
});


/*
$(document).ready(function(){
    $.ajax({  
      url:"http://10.255.32.250/left",dataType:'jsonp',data:'',jsonp:'callback',success:function(result) {  
            for(var i in result) {  
                alert(i+":"+result[i]);//循环输出a:1,b:2,etc.  
            }  
        },timeout:3000  
});  
})
*/
原文链接:https://www.f2er.com/json/289992.html

猜你在找的Json相关文章