zoukankan      html  css  js  c++  java
  • ajax封装

    //ajax封装
    function ajaxData(method, murl, mdata, success) {
    	$.ajax({
    		type: method,
    		url: murl,
    		dataType: "json",
    		contentType: "application/json",
    		data: mdata,
    		timeout: 8000,
    		success: function (data) {
    			success ? success(data) : function () {};
    		},
    		error: function (data) {
    			layer.msg("请求失败");
    		}
    	});
    }
    

      

    // 调用接口
    ajaxData("POST", webUrl, usrData, function (result) {
    	// console.log(result);
    	var data = result.data;
    	layer.msg(result.message);
    
    	if (result.code == '000') {
    		layer.msg('登录成功')
    		window.localStorage.setItem("GZ_PC_TOKEN", data.token);
    		window.localStorage.setItem("GZ_PC_USERID", data.userId);
    		window.location.href = 'index.html';
    	} else {
    		if (result.code == 'USER_COM007') {
    			layer.msg('账号或密码错误次数过多,该账号今日不能再登录');
    		} else {
    			layer.msg('账号或密码错误');
    		}
    	}
    
    })
    

      

  • 相关阅读:
    sizeof
    p与p->next
    每天学点java_Date类使用
    每天学点java_修饰符
    每天学点java_UML类图
    每天学点java_Arrays类
    每天学点java_插入排序
    每天学点java_for循环
    每天学点java_选择排序
    centos7 mysql
  • 原文地址:https://www.cnblogs.com/rockyan/p/8522105.html
Copyright © 2011-2022 走看看