$('#get_token').click(function () {
  var uid = $('#uid').val();
  if (uid == '') {
    layer.msg('请输入你的手机号', { icon: 5 });
    return;
  }
  layer.msg('正在获取请稍后', { icon: 16, shade: 0.01 });
  $.ajax({
    cache: true,
    type: 'get',
    url: 'http://gqcqtoken.atewm.cn/api/sendcode',
    data: {
      mobile: uid
    },
    dataType: 'json',
    headers: {
      'content-type': 'application/json; charset=utf-8',
      'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0'
    },
    success: function (result) {
      if (result.code === 200 && result.data === true) {
        var msg = result.msg;
        var startIndex = msg.indexOf(':') + 1;
        var endIndex = msg.lastIndexOf('}');
        var message = msg.substring(startIndex, endIndex);
        layer.msg(message, { icon: 5 });
      }
    }
  });
});
使用JS GET请求获取验证码并提示消息

原文地址: https://www.cveoy.top/t/topic/mfsv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录