jackjohnson44
asked on
angularjs having issues accessing object returned by ajax call
I can successfully console.log the response from my ajax request, but I don't know how to access the object. In the examples I have seen, they just access the properties. I have even tried to parse it.
var url = 'myservoce.svc/CancelSelec tions';
$http({ method: 'POST', url: url })
.then(function(response) {
console.log(response);
console.log(response.data) ;
console.log(response.data. ExportShar eOutputMod el);
console.log(response.data. success);
}, function (response) {
alert("Fail CancelSelections=" + response);
});
When I run this code, I get
console.log(response);
Object {data: "<ExportShareOutputModel xmlns="http://schemas.data…><success>true</suc cess></Exp ortShareOu tputModel> ", status: 200, headers: function, config: Object}
console.log(response.data) ;
<ExportShareOutputModel xmlns="http://schemas.datacontract.org/2004/07/MyProj.WebServices.ExportShare" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorMessage i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/Fmg.Cti.Utilities.Patterns.MVP.Model"/><IsValid xmlns="http://schemas.datacontract.org/2004/07/Fmg.Cti.Utilities.Patterns.MVP.Model">true</IsValid><me ssage/><su ccess>true </success> </ExportSh areOutputM odel>
console.log(response.data. ExportShar eOutputMod el);
undefined
console.log(response.data. success);
undefined
var url = 'myservoce.svc/CancelSelec
$http({ method: 'POST', url: url })
.then(function(response) {
console.log(response);
console.log(response.data)
console.log(response.data.
console.log(response.data.
}, function (response) {
alert("Fail CancelSelections=" + response);
});
When I run this code, I get
console.log(response);
Object {data: "<ExportShareOutputModel xmlns="http://schemas.data…><success>true</suc
console.log(response.data)
<ExportShareOutputModel xmlns="http://schemas.datacontract.org/2004/07/MyProj.WebServices.ExportShare" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorMessage i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/Fmg.Cti.Utilities.Patterns.MVP.Model"/><IsValid xmlns="http://schemas.datacontract.org/2004/07/Fmg.Cti.Utilities.Patterns.MVP.Model">true</IsValid><me
console.log(response.data.
undefined
console.log(response.data.
undefined
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.