title: jQuery get json data, match the ids, then append the custom field value
body: <p>I am trying to retrieve json data from zendesk, then compare the value of the ids in each ticket that is retrieved from the server with the id inside my table data. If the ids match, then I want to retrieve the custom field value inside the ticket with the matching id, and append it to the table data's that i have named with the product id. The idea is to target each "td/td",and automatically insert the custom field(product id) value when a new "td/td" tag is created. Please help :) The Object 99 at the top is the ticket, the id :175 is the id I am trying to match. the custom_field array[10] value is what I want to append and display. The issue I am having is that the data is not displaying after I append it. I think this has something to do with how I am accessing the data, comparing the ids, then appending the custom field. The array value is returning a -1 instead of comparing the IDs. This is the problem.</p>
  
  <pre><code>//first lets get some json data!
  var getjson = $.getJSON("/api/v2/tickets.json)",function (result) {
  $.each(result, function(i, field) {
   console.log('data',field);
  
   // now lets take the text id for each td and assign it as the id.   
   $(".sort &gt; tr &gt; td:nth-child(1)").each(function(){
  
  var textid = $(this).text();
    $(this).attr('id', textid);
   // if the ids match, give me the value of the custom field that is inside the     array of the matching id.     
    var arr = [field];
    var arrayvalues = $.inArray('id', arr);
   if ($(this).attr('id') == arrayvalues){
  
      /* if the ids match, give me the value of the 
     custom field that is inside the array of the matching id. */ 
  
     var returns = $.inArray('value',arr.custom_fields[i]);
  
  
   // now for each td lets append the value of the custom field.
     $(".sort &gt; tr &gt; td:nth-child(7)").each(function () {
      $(this).append(returns);  
     $(this).attr('id','product');
     })
  
   } 
  
    })
   });
  </code></pre>