I am facing an issue with a code snippet used in an Angular service:-
var formData = function (data) {
var fd = new FormData();
angular.forEach(data, function (value, key) {
fd.append(key, value);
});
return fd;
}
var updateUserPic = function (profilePic, callback, userId) {
var userId = userId || FRAME_API.proxyUserId; // jshint ignore:line
if (!_.isFunction(callback)) {
throw new Error('You must provide a callback function.');
}
$http({
method: 'POST',
url: '/Learn/PostUserProfile.ashx?action=profilepic&userid=' + userId,
data: {up_picfile: profilePic},
transformRequest: formData,
headers: { 'Content-Type': undefined}
}).success(function (data, status, headers, config){
callback([data, status, headers, config]);
return;
}).error(function (data, status){
console.log([status,data]);
callback(false);
return;
});
};
When checking using the Network tab in Chrome's Developer Tools, I can see that the response is 200 OK
. However, the issue arises as the error
callback is always triggered, even though the status is 200. Furthermore, the data
and status
parameters are received as undefined
.
Could there be any specific reason for this behavior?
The server response contains the following information:
{status: 'success', path: 'assets/profile/profilepicture.png'}
Additionally, it is important to note that I do not have control over this response as it originates from a vendor script running on the server which is inaccessible to me.