我得到的是控制台上的500错误,
我需要的是从控制台获得此响应并为此显示div我已完成此操作但它无法正常工作
error(function(response) {
if (response.status === 500) {
//showing div here
}
}
请告诉我解决此问题的正确方法
参考的整个代码
geniedoc.controller('uploadAppPrescriptionController', ['$scope','Upload','$timeout','MyService','$window',function($scope, Upload, $timeout,MyService,$window) {
$scope.isProcessing = false;
$scope.hidemultiLoader = false;
$scope.reportmultiLoader = false;
var counter=0;
$scope.uploadchoices = [{id: counter,
uploadedFile:''
}];
$scope.addNewUpload = function($event) {
counter++;
$scope.uploadchoices.push({'id': counter,
uploadedFile:''
});
console.log("Adding uploadedFile=>"+angular.toJson($scope.uploadchoices));
}
$scope.multiUploadFiles=function(appointmentId,patientEmailId){
$scope.isProcessing = true;
$scope.dynamic = 0;
$scope.hidemultiLoader = true;
console.log($scope.uploadchoices);
var docChoice=null;
var files=[];
for(var i=0;i<$scope.uploadchoices.length;i++){
files.push($scope.uploadchoices[i].uploadedFile);
console.log(files[i]);
}
Upload.upload({ method: 'POST',
file:files,
url: '/GenieDoc/api/user/upload-prescription?file='+files+ '&appointmentId=' +appointmentId + '&patientId=' + patientEmailId + '&docChoice=' + docChoice
}).progress(function(evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$scope.dynamic = progressPercentage;
// alert(progressPercentage);
$scope.uploadedFileName = evt.config.file.name;
console.log("uploadedFileName:"+$scope.uploadedFileName);
$scope.log = 'progress: ' + progressPercentage + '% '; // +evt.config.file.name
// + '\n' + $scope.log;
console.log("file process");
if(progressPercentage==100)
{
var iEl = angular.element( document.querySelector( '#pers' ) );
iEl.remove();
}
}).success(function(response) {
console.log("multiUploadFiles:=>"+angular.toJson(response));
$timeout(function() {
$scope.getDoctorPreviousAppointments();
$scope.getPatientReports();
},3000);
//$window.location.reload();
$scope.hidemultiLoader=false;
}).error(function(response, status) {
if (response.status === 500) {
alert(dadasdada);
}
});
}
提供了整个代码供参考,但我只需要从控制台获取500错误并做一些可能的事情吗?
提前致谢
答案 0 :(得分:0)
知道如何创建通话可能很有用,但如果我正在处理我的通话:它应该是这样的:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
//Do what you need to do on success
}, function errorCallback(response) {
if (500 === response.status) {
//Do what you need to do on a 500-response
}
});