title: Uncaught TypeError: Cannot use ‘in’ operator to search for ‘length’ in jquery-1.11.1.js:583
body: <p>I have two JS files as shown below (page1.js) and (page2.js for reference included below). I am basically referring to the following JSON response while working :</p>
  
  <pre><code>{
      "webservice_status": {
          "status": "SUCCESS",
          "message": ""
      },
  
      "my_document_list": [{
  
              "doc1": "445",
              "doc2": "445",
              "doc3": "445",
              "doc4": "445",
              "content": "Some text here to display"
          }
  
      ]
  }
  </code></pre>
  
  <p>Here is my <code>page1.js</code> related work:</p>
  
  <pre><code>$("#mydoclist").on('rowclick', function (event) {
              row = event.args.rowindex;
              datarow = $("#mydoclist").jqxGrid('getrowdata', row);
              var response = JSON.stringify(datarow, null, 10);
              var docID  = datarow["doc_id"];
              self.getMyDocumentContents(docID);
  
     });
  
  this.getMyDocumentContents = function (contentID_) {
  
     var data = {
        doc_id: contentID_
     }
  
     app_.get(data, self.processContent, app_.processError, url_name);
  
  }// End of getMyDocumentContents
  
  
  this.processContent = function(data_,textStatus_,jqXHR_) {
  
        data_ = app_.convertResponse(data_,jqXHR_);
        console.log("Checking for actual data_ content:", data_); 
        console.log("Actual Data Length Check for data_ content:", data_.my_document_list.length); 
  
        // debugger;
  
        var collection = data_.my_document_list.length[0].content;
        console.log("Collection Check",collection);
  
        //debugger;
  
         var source = {
           localdata: collection,
           datafields: [{
           name: 'content',
           type: 'string'
         }],
        datatype: "array"
        };
  
  
        var dataAdapter = new $.jqx.dataAdapter(source, {
  
             loadComplete: function (records) {
  
                  debugger;
  
                  var html;
  
            //Get data
              var records = dataAdapter.records;
              console.log("Check for records:",records.length);
              var length = records.length;
              html = "&lt;div style='margin: 10px;'&gt;&lt;pre&gt;" + records[0].content + "&lt;/pre&gt;&lt;/div&gt;";
              $("#docContentPanel").jqxPanel('clearcontent');
              $("#docContentPanel").jqxPanel('append',html);
  
              },
              loadError: function (xhr, status, error) { },
              beforeLoadComplete: function (records) {
  
              }
  
             });
  
              // perform data binding
              dataAdapter.dataBind();
  
              var panel = $("#docContentPanel");
              var content = panel.html();
              panel.jqxPanel({ width: '750', height: '500', scrollBarSize: 20 });
  
   }// End of processContent
  </code></pre>
  
  <p>Here is my <code>page2.js</code> related work:</p>
  
  <pre><code>this.get = function (data_, done_, fail_, webServiceKey_) {
  
          // Lookup the requested web service URL
          var url = https://documentlookup.com:8443/getmydocuments;
  
  
          // Create the AJAX request.
          $_.ajax({
              data: data_,
              method: "GET",
              url: url
          })
          .success(done_)
          .error(fail_);
      };
  
  // If the JSON data was returned with content type of "text/plain", parse as JSON before returning.
      this.convertResponse = function (data_, jqXHR_) {
  
          return (typeof(data_) === "object" ? data_ : JSON.parse(data_));
  
      };
  </code></pre>
  
  <p>Basically there is a list of rows displayed in a jqxgrid(not mentioned in the code above), when a user clicks on it
  <code>$("#mydoclist").on('rowclick</code> gets called , which calls the following function:
  <code>getMyDocumentContents</code> function: This function basically passes the <code>doc_id</code> inside data variable which is made
  available for the following function:
  <code>processContent:</code>
  In this function, I am trying to show in jqxPanel the value of the <code>content</code>which is in  <code>my_document_list</code> array.</p>
  
  <p><strong>Problem I am facing inside this function:</strong>
  As can be seen, there are debugger I placed at various places which are currently commented except at one place
  which is just below this line <code>loadComplete: function (records) {</code>
  I don’t get any error above this line <code>var dataAdapter = new $.jqx.dataAdapter(source, { ,</code> however, as soon as
  I place it inside it, I get the following error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot use ‘in’ operator to search for ‘length’ in jquery-1.11.1.js:583</p>
  </blockquote>
  
  <p>Where length is a numerical number which keeps on changing depending upon the length of value of <code>content</code> in the above JSON response.
  Could anyone tell me what’s going wrong? thanks in advance !
  Just in case needed, here is the jQuery line #583 isArraylike function :</p>
  
  <pre><code>function isArraylike( obj ) {
      var length = obj.length,
          type = jQuery.type( obj );
  
      if ( type === "function" || jQuery.isWindow( obj ) ) {
          return false;
      }
  
      if ( obj.nodeType === 1 &amp;&amp; length ) {
          return true;
      }
  
      return type === "array" || length === 0 ||
          typeof length === "number" &amp;&amp; length &gt; 0 &amp;&amp; ( length - 1 ) in obj; // THIS is LINE 583 which throws error
  }
  </code></pre>
  
  <p>Should I try changing the jQuery version?</p>