I am facing an issue with my Angular $http post service that communicates with a WCF service. The success handler in the http post is as follows:
.success(function (data) {
var response = JSON.parse(data);
var tsValid = response.Outcome;
deferred.resolve(tsValid);
}
However, I always get 'undefined' for tsValid. Upon adding some console logs, I noticed that the "data" variable looks like this:
"{\"Message\":\"Valid Timestamp\",\"Reference\":\"CheckTimestamp:Completed\",\"Outcome\":true,\"Data\":null,\"MessageCount\":0,\"MessageGUID\":null}"
After parsing, "response" appears as:
{"Message":"Valid Timestamp","Reference":"CheckTimestamp:Completed","Outcome":true,"Data":null,"MessageCount":0,"MessageGUID":null}
It seems like all JSON.parse did was remove the escape characters. When attempting to access response.Outcome, it returns undefined.
Curiously, manually parsing the "data" variable using JSON.parse in a command prompt works correctly and allows me to access response.Outcome.
Any suggestions on why JSON.parse isn't functioning properly within the success handler?
EDIT - I have updated the console output to eliminate the "data:" and "response:" tags that were initially included by me for identification purposes.