html页面通过json响应数据,我如何使用从另一个html文件json响应获取的数据使用角js...

我有不同的html页面,用户登录后,我有不同的数据被发回,我将不得不使用一些这数据连同我的下一篇文章到另一个html页面中的url。例如,如果用户应该登录,如果用户已经被认证,我将得到用户ID,性别以及一些其他数据用于另一个页面,因为我必须将其与其他活动一起发送。我如何使用从另一个html文件json响应获取的数据使用角js

做这样的事情捆绑或SharedPreferences在JAVA

这是代码为我的登录页面

var app = angular.module('myapp', [])

app.controller('empcontroller', function($scope, $http){

$scope.insertdata=function(){

console.log("triggered");

$http({

method: 'POST',

url: "myurl",

headers: {'Content-Type': 'application/x-www-form-urlencoded'},

transformRequest: function(obj) {

var str = [];

for(var p in obj)

str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));

return str.join("&");

},

data: {username: $scope.fname, pswd: $scope.lname}

})

.success(function(data, status, headers, config) {

var mssg = data.MESSAGE;

iqwerty.toast.Toast(mssg);

console.log(data);

if (data.RESULT === 1) {

window.location.href = 'homes.html';

} else {

$scope.errorMsg = "Login not correct";

}

})

.error(function(data, status, headers, config) {

$scope.errorMsg = 'Unable to submit form';

})

}});

这是结果我在控制台日志{ “RESULT” 获得:1, “MESSAGE”:“SUCCESSFUL”,“EMPID”:“2223444”} 如何在另一个html页面中使用我的数据(这是我的请求发送给给定url后的结果)(angularjs controller ..在另一个html文件中)。我怎么能在另一个HTML页面使用这个相同的用户名..因此,我要发送用户名和EMPID ..在我的其他HTML页面

+0

使用表单。这里是一个很好的例子: [another_answer](http://stackoverflow.com/a/13001878/1489912) –

+1

我使用的是angularjs ...而不是javascript ...感谢您的参考。 –

+0

angular.js是一个JavaScript库我的朋友.... –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值