美文网首页
数据调取归整-2

数据调取归整-2

作者: 幸宇 | 来源:发表于2018-03-14 14:48 被阅读6次

ajax,jsonp调取信息方式:

$(function(){
  // $("#t310").prepend(classCourse(310))
})
/* 课程 */
// http://bj.xdf.cn/school/categoryClassjsonp?categoryCode=186&one=310&size=4&count=4
function classCourse(id_,id,dom,cout){
  $.ajax({
      type:'get',
      url:"http://bj.xdf.cn/school/categoryClassjsonp?categoryCode="+id_+"&one="+id+"&size="+cout,
      dataType:"jsonp",
      jsonp: "callback",
    // jsonpCallback:"soukecourse",
      success:function(data){
          // console.log(data)
          var classCode=data;
          var detail='';
          var now_date=new Date().Format("yyyy-MM-dd");;
          now_p_date=parseInt(now_date.replace(/-/g,''),10);
          for(var i=0;i<classCode.length;i++){
              if(parseInt(classCode[i].startdate.substr(0,10).replace(/-/g,''),10)<now_p_date){
                  continue;
              }
              detail+='<tr><td>'+classCode[i].classname+'</td><td>'+classCode[i].startdate.substr(0,10)+'</td><td>'+classCode[i].classtimes+'次课'+'</td><td>'+classCode[i].price+'元</td><td class="boder-r"><a href="'+classCode[i].soukeline+'" target="_blank">免费了解课程</a></td></tr>'

          }
          if(detail!==''){
              // $('.kc-cont').find('tbody:first').prepend(detail);
              $("#"+dom).prepend(detail)
          }
          // console.log(detail)
          // return detail;
         

      },error:function(){
          alert("网络异常")
      }

  })
}
classCourse(186,310,'t310',4);
classCourse(186,325,'t325',6);
classCourse(186,326,'t326',5);
classCourse(186,327,'t327',5);
classCourse(186,328,'t328',5);
classCourse(186,318,'t318',4);
classCourse(186,315,'t315',4);
classCourse(186,316,'t316',4);

Date.prototype.Format = function (fmt) { //author: meizz   
  var o = {  
      "M+": this.getMonth() + 1, //月份   
      "d+": this.getDate(), //日   
      "H+": this.getHours(), //小时   
      "m+": this.getMinutes(), //分   
      "s+": this.getSeconds(), //秒   
      "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
      "S": this.getMilliseconds() //毫秒   
  };  
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
  for (var k in o)  
  if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
  return fmt;  
}  

// 校区信息调取

function schoolAdress(){
    $.ajax({
        type:'get',
        url:'http://bj.xdf.cn/school/yasixuexi.html',
        dataType:'jsonp',
        jsonp:'callback',
        success:function(data){
            var address=data.schoolMap;
            // console.log(data)
            var deta1='';
    
            
            for(attr in address){
                for(var i=0;i<address[attr].length;i++){
                    // console.log(address[attr][i].school_name)
                    deta1+='<li><span>'+address[attr][i].school_name+'</span><p><a href="http://bj.xdf.cn/school/schoolDetail_'+address[attr][i].school_id+'" target="_blank">'+address[attr][i].school_address+'</a></p></li>';
                }
               
            }

            // console.log(obj,obj2)
            if(deta1!==''){
                $('.ul_lef').prepend(deta1)
                
            }

        }
    })
}
schoolAdress();

使用轮播插件调取信息时注意,插件的加载顺序,否则插件的功能不可用,在success函数中调取成功之后再加载插件


  <script src="http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js"></script>
  <script type="text/javascript">
    $(function(){
      $.ajax({
        type:'get',
        url:"http://new.bj.xdf.cn/teacher/index.php?s=/api/index/getTjTeacher/part/2/num/8",
        dataType:"jsonp",
        jsonp: "callback",
        success:function(data){
          var item='';
          var datademo=data;
          // console.log(datademo);
          for(var i=0;i<datademo.length;i++){
                      item+='<div class="item"><img src="http://new.bj.xdf.cn/teacher/'+datademo[i].big_img+'" alt=""><div class="detail"><p class="p1">'+datademo[i].teachername
              +'</p><p class="p2">教授课程:'+datademo[i].souke_course+'</p><p class="p3">毕业院校:'+datademo[i].experience+'</p></div></div>'
          }
          if(item!==''){
            $('#owl-demo').prepend(item);
            showd();
          }
        }
      })
      function showd(){
        $("#owl-demo").owlCarousel({  
            items: 4,
            loop: true,
        });
      }
      
    })
  </script>
  <script src="js/owl.carousel.js"></script>

相关文章

  • 数据调取归整-2

    ajax,jsonp调取信息方式: 使用轮播插件调取信息时注意,插件的加载顺序,否则插件的功能不可用,在succe...

  • 数据调取归整-1

    在做ajax页面无刷新添加的时候,IE下遭遇Ajax缓存在IE下用Ajax请求某一页面,通常会因为缓存的原因而返回...

  • 纯JS实现表格分页

    思路: 1.讲表格内容存入一个变量 2.通过点击按钮从表格中调取数据 3.讲调取的数据填入表格中

  • python 支付-查询-退款-退款查询-调取excle每行数据

    单独调取excle每行数据对支付接口进行测试: 单独调取excle每行数据对订单查询接口进行测试: 单独调取exc...

  • Vue调取数据

    第一种:vue-resource 脚手架中安装命令:npm install vue-resource --sa...

  • 8月20日 工作情况

    砂石进厂 电工师傅把现阶段有插座的地方布好线,并归整大厅上方的线路 空调师傅来现场将教室的坐立式空调取下方便移位并...

  • 归整

    今天的关键词是归整,顾名思义是归纳整理的意思。 不知道大家的电脑桌面是否和我一样,远看密密麻麻很乱,左一个文件、右...

  • 归整

    收拾看与未看的书,床头两边都是;收拾写与未写的笔记本,一大抽屉都是。书控本控的我,总在这上面愿意买单,但沉浸其中的...

  • [2] 《R数据科学》绘图模板及练习

    上次的文章简单介绍了《R数据科学》,以及ggplot2中mpg的调取方式:1.直接键入mpg2.使用ggplot2...

  • 石乐志!AJAX提示GET(POST)[object%20Obj

    正在jQuery框架下写一个AJAX的GET请求,需求如下:(1)调取后台接口请求发送SESSION数据;(2)将...

网友评论

      本文标题:数据调取归整-2

      本文链接:https://www.haomeiwen.com/subject/ajrfqftx.html