I have the following function below which I am trying to re-write using $http provider. The documentation shows so many different ways of doing this and I cant get it right. Here is the function:
function Ingest(Filename, ID, baseUrl, logger){
var url = baseUrl + '/php/' + 'Ingest.php';
var dataString = 'Filename=' + encodeURIComponent(Filename) + '&ID=' + encodeURIComponent(ID);
$.ajax({
type: "POST",
url: url,
async: true,
cache: false,
data: dataString,
success: function(results){
logger.success('Ingestion process has been finished.', '', 'Success');
}
//fail
, error: function (jqXHR, textStatus, errorThrown){
alert("error:\r\n" + errorThrown);
}
});
}
and here is a sample of $http code:
$http({
method: 'POST',
url: config.appBaseUrl + '/php/' + 'Ingest.php',
data: { ID: encodeURIComponent(ID), Filename: encodeURIComponent(Filename) }
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Thank you