我正在尝试使用骨干网上传文件,并且需要在上传后对服务器进行API
调用。
为此,我们以下列方式编写了html代码。
div class="row">
<form id="dropzone" enctype="multipart/form-data" action="/planner.in/api/web/freshtimesummary/add/" method="post" class="fileHeight">
<div class="fallback">
<input type="file" class="setName button" id="setName" name="upload_tag_data" placeholder="Browse File & Upload">
</div>
<button type="submit" class="btn btn-block btn-primary" id="upload-button">Upload</button>
</form>
</div>
Javascript(骨干)代码:
function makingPPApiCall(collectionObj,requestData,successCallback,errorCallback,typeOfRequest){
collectionObj.fetch({
data:requestData,
"success":successCallback,
"error":errorCallback,
type:typeOfRequest
});
}
//view code
var uploadFilesView = Marionette.CompositeView.extend({
events: {
'submit form':'uploadFile'
},
uploadFile:function(event){
if (event.target.id===this.ui.formId) {
console.log("Test");
//making An Api call for summaryChart
event.preventDefault();
var successCallback=function(status,response){
console.log(response);
};
makingPPApiCall(makingAPICallForSummaryChartObj,"",successCallback,errorCallback,'POST');
};
}
});
收到以下错误:
我在这里做错了,任何人都可以帮助我。
感谢。