1

I have this jQuery below:

$.getJSON('../GetCities?', { term: inputString }, function (data) {            
  var anchorTagElements = '';
  console.log("line 39 ");
  $.each(data.items, function (i, item) {
    console.log("line 41 " );    
    anchorTagElements = anchorTagElements + '<a href=""><span class="searchheading">' +
      item.City + ', </span></a>';
  });
});

I can see the data is coming back from the server using firebug I can see the line 39 is printed to the log but line 41 is not meaning it failed right before the line 41 console.log

Error message I am getting is TypeError: e is undefined

error message

any ideas where to look at?

EDIT

Using jQuery non-minified I got:

TypeError: obj is undefined
length = obj.length,

It is failing while trying to get the length to evaluate i. I am not sure why I can see the data coming back correctly.

Here is the Data that comes back:

data

Simon Elliston Ball
  • 4,375
  • 1
  • 21
  • 18
Justin Homes
  • 3,739
  • 9
  • 49
  • 78

2 Answers2

2
$.each(data, function (i, item) {  
            anchorTagElements = anchorTagElements + '<a href=""><span class="searchheading">' +
                item.City + ', </span></a>';
});
Jashwant
  • 28,410
  • 16
  • 70
  • 105
-1

Try:

$(data.items).each(function (i, item) {

Also, try printing data to see if it is valid.

ATOzTOA
  • 34,814
  • 22
  • 96
  • 117