700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > html post 发送两次 angular 向后台发送数据 出现2次请求

html post 发送两次 angular 向后台发送数据 出现2次请求

时间:2021-07-10 12:18:13

相关推荐

html post 发送两次 angular 向后台发送数据 出现2次请求

因为要兼容IE7,没有用到route功能,在index.html页面include了菜单和登陆注册页面(header.html),在header页面中点击登陆时,后台接收到2次请求,一次无数据,第二次成功接收数据了。我检查页面了没有引用2次controller,但是不知为啥就是触发了2次请求。还请各位大神指点

html

登录 注册 135123456789 退出

购物车({{itemtotal}})

时尚款BBBB手表{{item.name}}

{{item.itemcount}}

-

+

{{item.price * item.itemcount | number: 2}} 删除

共({{itemtotal}})件商品{{total| number:2}}

去购物车结算

首页电话手表

武士款AAA

时尚款BBB

智能耳机论坛应用下载 手机号码:

请输入11位手机号码

请输入正确的手机号码

密码:

请输入密码

2-20个字符,可由中文、字母和数字组成

记住手机号码

注册新账号

忘记密码?

手机号码:

请输入11位手机号码

请输入正确的手机号码

验证码:

请输入正确验证码

2-20个字符,可由中文、字母和数字组成

密码:

请输入密码

2-20个字符,可由中文、字母和数字组成

确认密码:

两次输入的密码必须一致

两次输入的密码必须一致

阅读并同意入网服务协议服务条款、隐私政策

请先同意协议

js代码:

function LoginCtrl($scope,$http,$rootScope) {

// console.log("请求进入")

// 二级导航显示

$(".telWatch").on("mouseenter",function(){

$(".secNav").slideDown(function(){

$(".secNav").stop(true);

})//.stop(true,true);

return;

})

$(".telWatch").on("mouseleave",function(){

$(".secNav").slideUp(function(){

$(".secNav").stop(true,true);

});

return;

})

//登陆事件

$scope.showLogin = function(){

//页面层

layer.open({

type: 1,

title:"登录",

shadeClose: true,

skin: 'layui-layer-rim', //加上边框

area: ['500px', '500px'], //宽高

content: $('.login')

})

}

//注册事件

$scope.showRegin = function(){

//页面层

layer.open({

type: 1,

title:"注册",

shadeClose: true,

skin: 'layui-layer-rim', //加上边框

area: ['500px', '500px'], //宽高

content:$('.reg')

})

}

//注册

$scope.addUsers = function (item) {

//表单正常提交

if($scope.userForm.$valid){

if($scope.user.pwd != $scope.user.pwd2){

$(".pwd2").show();

return false

}else{

$(".pwd2").hide();

}

var url = "http://10.12.12.74:30030/gateway.do";

//正常提交表单

$http({

method : 'POST',

url : url,

data: {phone:phone,password:pwd},

header:headers

}).success(function(data, status) {

console.log(data.msg);

// alert(item.pwd,item.pwd2)

// $(".layui-layer-close1").click();

// $('.user').show();

// $(".loginItem").hide();

}).error(function(data, status) {

});

}

else{

$scope.submitted = true;

}

};

$scope.rebpwd = true;

//登陆

$scope.userlogin = function (phone,pwd) {

console.log(phone);

//表单正常提交

if($scope.loginForm.$valid){

//正常提交表单

var url = "http://10.12.12.74:30030/gateway.do";

var headers= {'Content-Type':'application/json'};

$http({

method : 'POST',

url : url,

data: {phone:phone,password:pwd},

header:headers

}).success(function(data, status) {

console.log(data.msg);

}).error(function(data, status) {

console.log(data.msg);

});

}

else{

$scope.submitted = true;

}

};

$scope.logout = function(){

alert("退出按钮")

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。