I have a PHP file which is retrieving value, id and time. Below is an example of the output of the PHP file when accessed directly:
//Using this
$print($json_encode($data))
//Returns this
"data":[
{
"y":7.76,
"x":"2015-05-04 01:23:37",
"CoilId":"E5E001B11"
}
]
Now when I use my factory method "getData" to retrieve the data and console log it, I end up with this:
"data":[
{
"y":7.76,
"x":1444017905000,
"CoilId":"E5E001B11"
}
]
Here is my factory:
myApp.factory('Widget', ['$http', function($http) {
var promise;
return{
getData: function(widgetType, widgetId, machineId, start, end){
promise = $http({
url: "angular/data/testData.php",
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: $.param({widgetType: widgetType, widgetId: widgetId,
machineId: machineId, start: start, end: end })
})
.success(function(data, status, headers, config) {
console.log(data);
})
.error(function(data, status, headers, config) {
console.log("Data: " + data + "
" + "Status" + status + "
"+ "Headers"
+ headers + "
" + "Config" + config + "
");
});
return promise;
},
};
}]);