jquery错误未捕获语法错误:输入意外结束
我使用jquery插件上传内容。但当我上传内容时,出现了一个错误,显示输入意外结束。下面是代码片段jquery错误未捕获语法错误:输入意外结束,jquery,jquery-plugins,Jquery,Jquery Plugins,我使用jquery插件上传内容。但当我上传内容时,出现了一个错误,显示输入意外结束。下面是代码片段 function uploadPacket(packet){ var xhr = new XMLHttpRequest(); var url = self.url + "?fileid="+self.fileDetails.fileId+"&token="+self.fileDetails.token+"&packet="+self.fileDetails.c
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);
}
请任何人帮助我这不是有效的JSON,无论返回什么作为
响应文本
,在这种情况下都是语法分析错误。请向我们展示您期望返回的字符串。它在mozila中运行良好,仅在chrome中发行