jeudi 16 juin 2016

how to rerieve single element value from a json response using jquery

Below is the code i'm using to retrieve a response from a server page using js

<body>
<div id="content">

</div>
<script>
var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      document.getElementById("content").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET", "https://api.certicasolutions.com/items/?x-ic-credential=finpdV1n1h2qt", true);
  xhttp.send();
</script>
</body>

and following is the json response

  {
   "completed":true,

    "totalItems":98891,

    "items":        
            [
        {"ia_biserial":"",
    "ia_bloomstaxonomy":"Creating"
    ,"ia_correctanswer":"",
    "ia_difficulty":"High",
    "ia_dok":"IV",
    "ia_extid":"231617",
    "ia_gradelevel":"GradeK",
    "ia_hasimages":"False",
    "ia_itemid":1,
    "ia_lang":"English",
    "ia_pointvalue":"2",
    "ia_pvalue":"",
    "ia_subject":"Math",
    "ia_teitype":"OR","ia_vendorid":"i-321813",
    "passages":[],
    "standards":[]

    },

    {
  "ia_biserial":"",
    "ia_bloomstaxonomy":"Creating",
    "ia_correctanswer":"",
    "ia_difficulty":"High",
    "ia_dok":"IV",
    "ia_extid":"231616",
    "ia_gradelevel":"GradeK",
    "ia_hasimages":"False",
    "ia_itemid":2,
    "ia_lang":"English",
    "ia_pointvalue":"2",
    "ia_pvalue":"",
    "ia_subject":"Math",
    "ia_teitype":"OR",
    "ia_vendorid":"i-321812",
    "passages":[],
    "standards":[]
    },

i want to display only item id's "ia_itemid" in a select drop down list using jquery ,need help to do above thank you

Aucun commentaire:

Enregistrer un commentaire