I am trying to compare 2 arrays. One is taken from DOM, generated by .split(" "), the other I would like to be retrived by $.get call.
All is working fine if I test the dictionary array manually. Example:
// var dictionary = ["in", "the"]; // <- this one works
var dictionary = $.getJSON('job/dictionary/en');
$(this).keyup(function() {
var words = $(this)
.text()
.split(" "),
words_final = [],
i = 0;
jQuery.grep(words, function(word) {
if (jQuery.inArray(word, dictionary) == -1) words_final.push(word);
i++;
});
});
Response from this URL is Content-Type: application/json with response body:
[
"in",
"the"
]
Apparently... then I try to run $.getJSON('job/dictionary/en') in chrome dev tools, I get an object back with responseText: "["in","the"]"
I've tried with $.get() as well with the same result.
Any help really appreciated.