jQuery - parsing JSON data - Having trouble with variable name

前端 未结 3 1671
刺人心
刺人心 2021-02-09 17:07

My first delve into working with JSON data. I have a bit of experience using jQuery though.

I\'m posting to this URL (tumblr api): jyoseph.com/api/read/json

What

相关标签:
3条回答
  • 2021-02-09 17:56

    If there are dashes in the names you'll need to access them differently. Change var photo500 = this.photo-url-500; to read var photo500 = this["photo-url-500"];.

    0 讨论(0)
  • 2021-02-09 17:59

    Use the bracket notation to access the members:

    var photo500 = this['photo-url-500']; 
    
    0 讨论(0)
  • 2021-02-09 18:12

    Please note it is best not to append inside each iteration. Better to append to a string or push to an array then append once after the iterator has finished. Appending to the dom is expensive.

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