Tuesday 15 April 2014

javascript - Iterating through JSON object -


Because I'm quite new in JSON and jQuery, I'm struggling to repeat through an object, due to which I load sofar with the following code:

  $ Ajax ({url: source, data type: 'Jason', success: function (oBJ) {// wave AN SACS-MOLDING ZEEN WENNER DE data Ingeladen console.log ("success");}, error: function (obje) {// wave AN error-molding ZEAN WENNER DE DATA ANIET NGEL NGLeden is warning ("error");}, complete: function (obj) {Console.log (obj);}}); Unfortunately the structure of JSON is a bit complicated for my taste, but since it is an external source (via YQL) nothing can be changed about it:  
 <">" "" {"Census": 1, "created": "2013-06-21T11: 42: 57Z", "Lang": "N-US", "Diagnosis": {"Publicly Eligible": "Correct", " Url ": {" execution-start-time ":" 1 "," execution-stop-time ":" 1868 "," execution-time ":" 1867 "," proxy ":" default "," content ": "Content Time": "User-Time": "1868", "Service-Time": "1867", "Build-Up Jan ":" 37740 "}," Result ": {" Viewers ": {" Toplavelentry ":" 0 "," Viewant ": [{" Date ":" 2013-06-11 "," Noted ":" A "[15]" "15D7F7A15C0DAE", "Entidated": [{"Column Number": "0", "Name", "2F", "Position": "1", "Brother Sister": "0", "Unid" : "Text": "title", "text": "title", "text:", "text": "text": "" "column number": "1", "name": "coprejel", "text" "Number": "3", "name": "bruo", "lesson": "2", "name": "tusencopje", "text": "introduction text of newsitem 1"}, {"column number": " ":" Image of NewsTime1 "}}, {" t "", "", "", "", "", "", "", "", "", " "[Column: column" "", "name": "data_w_wintini", "text": "2013-05-29"}, {"column number": "1", "name": "coprejel", " Text ":" title ":" name ":" 2 "," name ":" tusencope "," text ":" introduction text of newsitem 2 "}, {" column number ":" 3 "," name ":" "Content of newsitem2"}, "column number": "4", "name": "imagery", "text": "image image of newsitem 2"}]}]}}}   

what I want to accomplish Pranghee is an element in my HTML file to print something like the following:

  Title of Newsitem 1 title of Newsitem 2   

I am sure Since then I'm good to remove other things from the file. With various things I am trying to understand, I understand, a $ at various obj.viewentry [0] options. I get an undefined error by using a new loop. When I try to reach more specific, then.

  $ Each (obj.viewentry, function (index, value) {console.log (this.entrydata [0]);});   

The return I received is a jQuery error, type: error: e is undefined. Although I'm pretty sure that the last code is 'Dummy for jQuery', the other answers I am seeking for this morning did not really give me more clarity.

Try to use it:

  $ Each (obj.query.results.viewentries.viewentry, function (index, value) {$ .each (value.entrydata, function, index) value {if (value.name == "kopregel") console.log (value .text);});});   

Here's how it works:

No comments:

Post a Comment