1 $.ajax({
2 type: 'POST',
3 url: '/login',
4 dataType: 'json',若出现跨域请求请使用'jsonp'
5 data: {
6 'userName': userName,
7 'password': password
8 },
9 success: function (e) {
10 if (e.code == 200) {
11 //这里登录成功后进行页面跳转
12 window.location.href = '/index';
13 alert(e.message);
14 } else {
15 alert(e.message);
16 }
17 },
18 error: function () {
19 alert("Error!");
20 }
21 });
1 $.ajax({
2 method: 'POST',这里不同了
3 url: '/login',
4 data: {
5 'userName': userName,
6 'password': password
7 },
8 success: function (e) {
9 if (e.code == 200) {
10 window.location.href = '/index';
11 alert(e.message);
12 } else {
13 alert(e.message);
14 }
15 },
16 error: function () {
17 alert("Error!");
18 }
19 });