Link to home
Start Free TrialLog in
Avatar of jackjohnson44
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/CancelSelections';
                $http({ method: 'POST', url: url })
                    .then(function(response) {
                        console.log(response);
                        console.log(response.data);
                        console.log(response.data.ExportShareOutputModel);
                        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</success></ExportShareOutputModel>", 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><message/><success>true</success></ExportShareOutputModel>



                        console.log(response.data.ExportShareOutputModel);
undefined
                        console.log(response.data.success);
undefined
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial