【发布时间】:2017-07-31 11:52:57
【问题描述】:
当我运行这个函数时,我得到了一个 JSON 对象,如图所示 我只想显示一个选定的参数,比如用户名。
[displaying json object on running this function][1]
$scope.signUp = function () {
$http({
method: "post",
dataType:'json',
url: "http://192.168.0.60/api/Customer/CustomerLoginService",
crossDomain : true,
data: {
'username': $scope.username,
'password': $scope.password,
'entrytoken': $scope.entrytoken
},
headers: { 'Accept':' text/plain','Content-Type': 'application/json' }
}).then(function success(data) {
alert("success function");
var obj=JSON.stringify(data);
alert(obj);
});
如何显示单个参数。
【问题讨论】:
-
你不需要对数据进行字符串化,只需做 data.username
-
@Lekens 输出未定义
-
执行此操作以检查 json 中的元素,....console.log('DATA=',data);打开控制台查看您的数据可能存在用户名