title: json to javascript variable zendesk
body: <p>I'm trying to retrieve the amount of open tickets from the zendesk api for a specific user. However I can't seem to get it to work. I keep getting this error: </p>
  
  <pre><code>Uncaught TypeError: Cannot read property '500' of undefined
  </code></pre>
  
  <p>The json format:</p>
  
  <pre><code>{
  "user": {
      "id": 500,
      "url": "https://zendesk/api/v2/users/500.json",
      "name": "Random name",
      "email": "not important",
      "created_at": "2016-05-18T15:26:43Z",
      "updated_at": "2018-07-04T06:23:35Z",
      "time_zone": "Brussels",
      "phone": null,
      "shared_phone_number": null,
      "photo": {
          "url": "https://google.com",
          "id": 504,
          "file_name": "keep-calm-and-shut-up-im-your-system-administrator.png",
          "content_url": "https://google.com",
          "mapped_content_url": "https://google.com",
          "content_type": "image/png",
          "size": 3298,
          "width": 80,
          "height": 50,
          "inline": false,
          "thumbnails": [
              {
                  "url": "https://google.com",
                  "id": 90752965,
                  "file_name": "not important",
                  "content_url": "https://google.com",
                  "mapped_content_url": "https://google.com",
                  "content_type": "image/png",
                  "size": 3298,
                  "width": 32,
                  "height": 20,
                  "inline": false
              }
          ]
      },
      "locale_id": 1005,
      "locale": "nl",
      "organization_id": 501,
      "role": "admin",
      "verified": true,
      "external_id": null,
      "tags": [],
      "alias": "",
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": "2018-07-04T06:23:35Z",
      "two_factor_auth_enabled": null,
      "signature": "",
      "details": "",
      "notes": "",
      "role_type": null,
      "custom_role_id": null,
      "moderator": true,
      "ticket_restriction": null,
      "only_private_comments": false,
      "restricted_agent": false,
      "suspended": false,
      "chat_only": false,
      "default_group_id": 503,
      "user_fields": {
          "agent_ooo": false
      }
  },
  "open_ticket_count": {
      "500": 15
  }}
  </code></pre>
  
  <p>This is my javascript code:</p>
  
  <pre><code>        &lt;script&gt;
      function getJSON(url) {
      var resp ;
      var xmlHttp ;
  
      resp  = '' ;
      xmlHttp = new XMLHttpRequest();
  
      if(xmlHttp != null)
      {
          xmlHttp.open( "GET", url, false );
          xmlHttp.send( null );
          resp = xmlHttp.responseText;
      }
  
      return resp ;
  }
     var gjson ;
      gjson = getJSON('https://zendesk.com//api/v2/users/me.json? 
      include=open_ticket_count');
  
  console.log(gjson.open_ticket_count["500"]);
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Can someone help me out? I'm not sure of what I'm doing wrong (the zendesk urls are the correct urls in the actual script and they can access it)</p>
  
  <p>TLDR: I need to retrieve the variable from: open_ticket_count from a json. </p>
  
  <p>Thank you!</p>