欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

今天试着用原生axios以及jquery下的axios请求数据

程序员文章站 2022-03-10 08:36:12
axios.get("https://route.showapi.com/9-2", { params: { area: "北京", showapi_appid: "428326", showapi_sign: "b7abf533098a45f8b15d20078311fa98", showapi_timestamp: 20201112041810, showapi_r...
axios.get("https://route.showapi.com/9-2", {
          params: {
            area: "北京",
            showapi_appid: "428326",
            showapi_sign: "b7abf533098a45f8b15d20078311fa98",
            showapi_timestamp: 20201112041810,
            showapi_res_gzip: 0,
          },
        })
        .then((res) => {
          console.log(res.data);
        });

而jquery中的方法为:

$.ajax({
  type: 'post',
  url: 'http://route.showapi.com/9-2',
  dataType: 'json',
  data: {
    "showapi_timestamp": formatterDateTime(),
    "showapi_appid": 'just_test_app', //这里需要改成自己的appid
    "showapi_sign": 'just_test_sign',  //这里需要改成自己的应用的密钥secret
    "areaCode":"530700",
    "areaid":"101291401",
    "area":"丽江",
    "needMoreDay":"0",
    "needIndex":"0",
    "need3HourForcast":"0",
    "needAlarm":"0",
    "needHourData":""
  },

  error: function(XmlHttpRequest, textStatus, errorThrown) {
      alert("操作失败!");
  },
  success: function(result) {
      console.log(result) //console变量在ie低版本下不能用
      alert(result)
  }
});

本文地址:https://blog.csdn.net/qq_45305088/article/details/109635349