简体   繁体   English

JSON.parse() 在 Linux 和 Mac 上不起作用

[英]JSON.parse() does not work on Linux and Mac

I am getting a json response from backend and need to parse the json in frontend.我从后端收到 json 响应,需要在前端解析 json。 Here is my code:这是我的代码:

this.on("success", function(file, response, action) {
                
                response = JSON.parse(response);      
                console.log(response.id);               
                
            });  

When run the code, it said the following.运行代码时,它说以下内容。

 Uncaught SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)

Note: The code do works well on Windows and here is the repsonse.注意:代码在 Windows 上运行良好,这是响应。

{message: 'Uploaded successfully...', id: 'a690d9b3-4f1e-48a0-83ac-42a2ea7cb904'}

It looks like your response is correct.看起来你的回答是正确的。 I think you need to check your form and model in backend.我认为您需要在后端检查您的表格和 model。 If form is not valid or model include the null=true and so on.如果表单无效或 model 包含 null=true 等。 I mean you would troubleshoot your response from backend.我的意思是你会从后端对你的响应进行故障排除。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM