search

Home  >  Q&A  >  body text

javascript - How to parse this json data

Why when I use ajax data.SERVERPARTObject it displays undefined

漂亮男人漂亮男人2821 days ago497

reply all(4)I'll reply

  • 世界只因有你

    世界只因有你2017-05-19 10:42:13

    It is possible that the data format returned by the background is string type data, not a js object. Use JSON.parse to convert it into an object.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-19 10:42:13

    data.SERVERPARTObject[0] try

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:42:13

    You can print the type of data first

    console.log(typeof data);

    If it is a string, then JSON.parse(data);

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-19 10:42:13

    Did you miss a sentence in the ajax you wrote? dataType: 'json',跟上面的JSON.parse(data)One meaning

    reply
    0
  • Cancelreply