jquery

来源:互联网 发布:gotv源码ts 编辑:程序博客网 时间:2024/06/11 12:41
$.ajax({  type: 'POST',  url: url,  xhrFields:{  withCredentials : true //跨域  },  data: JSON.stringify(user),  success: function(result) {  if(result.code == 0){  console.log("登陆成功");  }else{  $(".login-error").show();  $(".login-error").html(result.message);  }  },  error: function(XMLHttpRe,textStatus,errorThrown){  $(".login-error").show();  $(".login-error").html("服务器异常:" + textStatus);  },  dataType: "json",  contentType: "application/json;charset=UTF-8"//需要配置一下,默认为application/x-www-form-urlencoded;charset=utf-8});