JQuery getJSON - ajax parseerror

后端 未结 17 1825
南笙
南笙 2020-12-01 13:04

I\'ve tried to parse the following json response with both the JQuery getJSON and ajax:

[{\"iId\":\"1\",\"heading\":\"Management Services\",\"body\":\"

相关标签:
17条回答
  • 2020-12-01 13:19

    If anyone is still having problems with this it's because your response needs to be a JSON string and content-type "application/json".

    Example for HTTP in asp.net (c#):

    public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            context.Response.Write("{ status: 'success' }");
        }
    

    hth,

    Matti

    0 讨论(0)
  • 2020-12-01 13:22

    You could have it return as text and then parse it with the json.org parser
    To see if it works any differently

    0 讨论(0)
  • 2020-12-01 13:22

    I received a similar error. Took me a while to find out - little did I know that PHP has not (natively) supported JSON since PHP5.2. Critical reminder...

    0 讨论(0)
  • 2020-12-01 13:23

    Pleas note that in the question there is a syntax error. The line with

    x.overrideMimeType("application/j-son;charset=UTF-8");
    

    should read

    x.overrideMimeType("application/json; charset=UTF-8");
    

    This makes a big difference too.

    0 讨论(0)
  • 2020-12-01 13:25

    Yesterday at $. Ajax still no mistakes, today is quoted the mistake, some say parsererror jquery version of the problem, what I use is jquery-1.3.2.min.js, yesterday. This edition also done, today is washed-up. Data sources: no change. Don't know what reason be?

    0 讨论(0)
  • 2020-12-01 13:27

    Did you try XML-encoding the HTML (i.e. <H1>)?

    0 讨论(0)
提交回复
热议问题