我正在使用jquery插件上传内容。但是当我上传一个内容时,有一个错误显示意外结束输入。这是代码片段
function uploadPacket(packet){
var xhr = new XMLHttpRequest();
var url = self.url + "?fileid="+self.fileDetails.fileId+"&token="+self.fileDetails.token+"&packet="+self.fileDetails.currentPackage;
//alert(url);
var fileDetails = self.fileDetails;
updateProgress(fileDetails,0);
xhr.open('POST', url, true);
xhr.onprogress = function(e){
updateProgress(fileDetails,e.position);
// var percentComplete = (e.position / e.totalSize)*100;
//console.log(percentComplete);
// progressBar.value = percentComplete;
// loadedSize.innerHTML = e.position;
// speed.innerHTML = ((e.position-startedBytes)/1024)/((new Date().getTime()-timer)/1000)+ " kbps";
};
/**
* If the server uploaded the packet successfully, then go to updateDetails() where log the success,
* and initiate uploading the next package (if we not paused while it uploaded)
*/
xhr.onload = function (e){
//alert(e);
var response = JSON.parse(xhr.responseText); // here is the error showing
if (response.action=="new_packet" && response.result=="success"){
updateDetails(fileDetails);
}
};
xhr.send(packet);
}
请任何人帮助我