简体   繁体   English

未捕获的语法错误:JSON.parse 处的 JSON 输入意外结束(<anonymous> )</anonymous>

[英]Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse(<anonymous>)

I'm working on an ajax call to an API.我正在处理对 API 的 ajax 调用。 and upon calling this call, I keep running into this error.在调用这个调用时,我一直遇到这个错误。 Please help.请帮忙。 Ive been trying at this for hours and not sure what the issue is.我已经尝试了几个小时,但不确定问题是什么。 Ive taken out the我已经取出了

JSON.parse and added them back to see if that will help but still no progress. JSON.parse并将它们添加回来看看是否有帮助,但仍然没有进展。

 $.ajax({
        type: "POST",
         //url: 'http://aeM/api/getDataId',
        url: '/bin/soupservice.getDataAccordToId.html',
        //async: false,
        data: IDschema,
        //contentType: "application/json",
        beforeSend: function () {
            // Show image container
            $("#wait").css("display", "block");
        },
        
    success:function (data, textStatus, jqXHR) {
    console.log(jqXHR.status);
   
        if (JSON.parse(data)) {
            let fileDeviceData = [];
            let uploadDate = [];
            fileDeviceData = data;
            let deviceNameFromFileData = [];
            $.each(JSON.parse(data), function (i, element) {
                dataInFile.push(element.file);
                deviceNameFromFileData.push(element.deviceName);
                //push an object while interacting with API. used to get similar index locations for later use
                duplicateIdCheckedList.push({
                    "deviceName":element.deviceName,
                    "lastUploadDate":element.lastUploadDate.split(" ")[0] ,
                    "fileName": element.deviceName+ " "+element.lastUploadDate.split(" ")[0],
                    "id":element.id
                    
    
                });
                let utcTime = element.lastUploadDate;
                let utcText = moment(utcTime).format("L LT");
                let anotherway = moment.utc(utcTime).local().format("L LT");
                let firstConvertedString = anotherway.split("/").join("-").replace(",", "");
                uploadDate.push(firstConvertedString.split(":").join("-").replace(",", ""));
            })
            //call on the findDuplicateIndex function to organize all the files that will be consolidated together
            duplicates=findDuplicateIndex(duplicateIdCheckedList);
            valuesforBrowserTime = uploadDate
            exportAsTxt(deviceNameFromFileData, valuesforBrowserTime);
        }

I see you are requesting a .html file and passing data to JSON.parse that expect a JSON format.我看到您正在请求一个.html文件并将数据传递给JSON.parse ,该文件需要JSON格式。

You may need to parse using a different method.您可能需要使用不同的方法进行解析。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的 SyntaxError:JSON.parse 处的 JSON 输入意外结束(<anonymous> ) - Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) 未捕获的语法错误:JSON 输入的意外结束:在 JSON.parse(<anonymous> )</anonymous> - Uncaught SyntaxError: Unexpected end of JSON input : at JSON.parse (<anonymous>) 未捕获的语法错误:JSON.parse 处的 JSON 输入意外结束(<anonymous> ) 在 XMLHttpRequest。<anonymous> ((指数):32)</anonymous></anonymous> - Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at XMLHttpRequest.<anonymous> ((index):32) SyntaxError:JSON.parse 处的 JSON 输入意外结束(<anonymous> )</anonymous> - SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) 语法错误:JSON.parse 处的 JSON 输入意外结束(<anonymous> ) on(&quot;数据&quot;) - SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) on("data") 未捕获的语法错误:JSON.parse 处的 JSON 输入意外结束 - Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse Uncaught SyntaxError:执行JSON.Parse时输入意外结束 - Uncaught SyntaxError: Unexpected end of input While doing JSON.Parse 未捕获到的SyntaxError:JSON中的意外令牌&lt;在JSON.parse位置0处( <anonymous> ) - Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) Uncaught SyntaxError: Unexpected token & in JSON at position 1 at JSON.parse (<anonymous> )</anonymous> - Uncaught SyntaxError: Unexpected token & in JSON at position 1 at JSON.parse (<anonymous>) 未捕获的SyntaxError:JSON.parse中位置0的JSON中的意外标记a( <anonymous> ) - Uncaught SyntaxError: Unexpected token a in JSON at position 0 at JSON.parse (<anonymous>)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM