【发布时间】:2018-02-14 21:03:41
【问题描述】:
服务器将对象返回为“undefined”和“XMLHttpRequest cannot load the "URL" Response for preflight is invalid (redirect)的原因是什么。。 p>
应用程序流程 - 它只是一个普通的邮政服务,向服务器发送文档详细信息作为回报应该返回一个包含各种参数的对象,但它返回'undefined'
发布文件的服务
fileUpload: {
method: 'POST',
url: config.apiPath + 'employee/service/pushRecords', //this is the URL that should return an object with different set of parameters (currently its returning Error error [undefined])
isArray: false,
params: {},
headers: {
'content-type': undefined
}
},
创建表单数据 w.r.t 文档后我使用的以上服务
function registerFormdata(files, fieldName) {
files = files || [];
fieldName = fieldName || 'FileSent';
var returnData = new FormData();
_.each(files, function (file, ind) {
returnData.append(fieldName,file);
});
return returnData;
}
现在这是使用这些服务的控制器
function sendFilesToServer() {
var formData = employeePushService.registerFormdata(directive.dropZoneFile.fileToUpload);
return docUploadService.fileUpload(formData)
.then(function(document) {
// Extra actions but here the server should be returning an object with set of parameters but in browser console its Error [undefined]
}).catch(logger.error);
}
【问题讨论】:
标签: javascript angularjs angularjs-directive angularjs-scope