0
<script>
/*
{
      "batchcomplete": "",
      "query": {
        "pages": {
          "125293": {
            "pageid": 125293,
            "ns": 0,
            "title": "Copper",
            "revisions": [
              {
                "contentformat": "text\/x-wiki",
                "contentmodel": "wikitext",
                "*": "Some Data"
             }
            ]
          }
        }
      }
    }
*/
var link ="https://en.wikipedia.org/w/api.php?action=query&titles=Copper&prop=revisions&rvprop=content&format=json";
$.ajax({
    url: link,
    dataType: 'JSON',
    type: 'get',
    cache: false,
    success: function(data) {
        $(data).each(function(index, value) {
            //print value.child
            document.getElementById('data').innerHTML = value.query.pages.125293.title;
        });
    }
});
</script>

Please provide me with and example on how to modify my code to get to the title child. Other alternatives are appreciated but please keep it simple. It seems that a lot of users just tend to copy and paste material from other site with not even a hint of how JQUERY works. So please don't paste some one else work. Thanks in advance.

  • 1
    Is your code working ? What error do you have ? – Weedoze May 04 '17 at 06:53
  • if I print value only I get [object Object]. –  May 04 '17 at 06:59
  • if I print value.item I get undefined and value.query.pages.125293.title gives me nothing. –  May 04 '17 at 07:00
  • i am using at the header –  May 04 '17 at 07:01
  • remove `$(data).each(...)` - Use directly `data.value` – Weedoze May 04 '17 at 07:06
  • I did success: function(data) { document.getElementById('data').innerHTML = data.query.pages.125293.title; } but nothing –  May 04 '17 at 07:11
  • What is inside data ? – Weedoze May 04 '17 at 07:14
  • document.getElementById('data').innerHTML = data.query.pages.125293[2].title; –  May 04 '17 at 07:15
  • Use `console.log(data)` to see what is inside – Weedoze May 04 '17 at 07:16
  • I used alert(data); and nothing. –  May 04 '17 at 07:20
  • Dude, this will be my last comment to help. If I am telling you to use `console.log(data)` it is for a reason. `alert(data)` won't display an object ! + be clearer when saying what happens : **nothing**..What does it mean ? An error ? undefined ? empty ? – Weedoze May 04 '17 at 07:22
  • ok I tested on jsbin and got an error on the console: "error" , "ReferenceError: '$' is undefined –  May 04 '17 at 07:22
  • hey thanks for the help, you may go then. No need for aggravations. –  May 04 '17 at 07:24
  • We are here to help you. If we are asking for more details - Please answer with more details. If we ask you do test something - test it, don't try to change it. `'$' is undefined` only means that you did not include jquery – Weedoze May 04 '17 at 07:25

0 Answers0