2

so im not sure what im doing wrong but im trying to check to see if one of the items in my get json list is in the url. This seems very easy but nothing is working for me.

$.getJSON("/extra/api/api/GetProductProgramList", function(data) {
this.name = data.SpecialtyName;
//updated not to confuse jquery with hash
this.hashtag = data.hashtag;

});

and then

if (currentLocation.indexOf(hashtag) >= 0) {
    self.filterValues.push(name);
}

but i keep getting 0x800a1391 - JavaScript runtime error: 'hashtag' is undefined

UPDATE

example: my url looks like this: localhost/dvd/adventure

GetProductProgramList.json provides a list of specialties:

+---------------+-----------+
| specialtyname |  hashtag  |  
+---------------+-----------+
| Adventure     | adventure |  
| Sci-Fi        | sci-fi    |  
| Action        | action    |  
| Fantasy       | fantasy   |  
+---------------+-----------+

so im basically trying to find if the url contains and item from the json list. then pushing that name to my function.

NeoSketo
  • 525
  • 1
  • 7
  • 26
  • see http://stackoverflow.com/questions/298503/how-can-you-check-for-a-hash-in-a-url-using-javascript for example –  Oct 27 '15 at 18:22
  • in my example there isnt a hashtag. instead im looking for the tag name itself. – NeoSketo Oct 27 '15 at 18:24

1 Answers1

1

this.hash = data.hashtag; will set either jQuery.hash or whatever element you are referring to. You need to ensure that you're setting the correct property name to the correct object.

Bwaxxlo
  • 1,860
  • 13
  • 18