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

时尚款BBBB手表{{item.name}}
{{item.itemcount}}
{{item.price * item.itemcount | number: 2}}
删除
-
共({{itemtotal}})件商品
{{total| number:2}}
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("退出按钮")
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你的
userLogin请求跨域了,因此先需要一次HTTP OPTIONS请求,来判断对应server是否允许资源访问。参见 http://stackoverflow.com/ques...
你的userLogin请求跨域了,因此先需要一次HTTP OPTIONS请求,来判断对应server是否允许资源访问。