“SyntaxError: Unexpected token < in JSON at position 0”

前端 未结 30 2071
花落未央
花落未央 2020-11-22 04:39

In a React app component which handles Facebook-like content feeds, I am running into an error:

Feed.js:94 undefined \"parsererror\" \"SyntaxError: Un

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 05:15

    I my case the error was a result of me not assigning my return value to a variable. The following caused the error message:

    return new JavaScriptSerializer().Serialize("hello");
    

    I changed it to:

    string H = "hello";
    return new JavaScriptSerializer().Serialize(H);
    

    Without the variable JSON is unable to properly format the data.

提交回复
热议问题