I've a problem with an ajax call in Knockout.js
exports.prepareCashbackReceipt = function () {
exports.receiptUrl(null);
exports.isLoadingReceipt(true);
$.post('/api/user/PrepareReceipt', JSON.stringify({ receiptNr: exports.data().NextReceiptNr(), amount: exports.cashbackPts() }))
.done(function (retunedData) {
console.log(retunedData);
exports.isLoadingReceipt(false);
exports.receiptUrl(retunedData.AWSObjectKey);
})
.fail(function (ex) {
toastr['error']('Unable to create receipt, please try again later');
console.log(JSON.stringify(ex));
exports.isLoading(false);
exports.isLoadingReceipt(false);
})
}
the PrepareReceipt method creates a pdf file (the receipt) and returns a string with the id of the receipt.
Now, the pdf is correctly created, and also the id is returned. But, for some reason the call fails.
I also tried to return a json string, and it fails again... is there a property, for example near responseText, to look into, that helps me to understand what is going wrong?
Update
the preceiding object that i logged in console is this https://drive.google.com/file/d/16a7GhCB1xHfHnkRKYCuGsrPgp_-psN4A/view?usp=sharing
here is the full chrome log https://drive.google.com/file/d/1yzPeIp1APhhytSUk7pzV-A5LZ-T4LLcn/view?usp=sharing
but I think it's not so interesting to determine what wrong is happening excepting for this string
[18604:10208:0801/151001.007:INFO:CONSOLE(152)] "[object Object]", source: https://localhost:44378/Scripts/ViewModels/portfolio.js (152)
but the chrome debugger console drew my attention to this:
so, in this moment, I'm turning my attention to the view.
Thanks in advance