jQuery remote autocomplete callback error-Collection of common programming errors
I’ve got a tricky problem here. Using jQuery mobile autocomplete to query the LinkedIn companies API, I see this error in my console:
Uncaught TypeError: Property 'callback' of object [object Object] is not a function (anonymous function)
It’s inconsistent. Sometimes it doesn’t show up and I see the right search results. But it does appear when the immediate query term isn’t return any results (even if I am in the middle of typing a query).
I know I’m at least receiving the right results somewhere because I see them in my Chrome dev tools, but when the above error pops up in my console, the most recently updated search results don’t show up in my browser. For example, typing in “BlackRock” returns the appropriate search results from LinkedIn in a jsonp object (though NOT in my browser):
callback({
"companies": {
"_count": 10,
"_start": 0,
"_total": 91,
"values": [
{
"id": 4764,
"name": "BlackRock"
},
{
"id": 405075,
"name": "DSP BlackRock Mutual Fund"
},
{
"id": 2289863,
"name": "Blackrock Search Ltd"
},
{
"id": 2766517,
"name": "Blackrock Lender Services"
}
...
These are what I SHOULD be seeing in my browser. The results I see in my browser are these (apparently results for “Black”):
callback({
"companies": {
"_count": 10,
"_start": 0,
"_total": 10122,
"values": [
{
"id": 2845927,
"name": "BeatingJack"
},
{
"id": 758374,
"name": "Black Book"
},
{
"id": 3042437,
"name": "Wine in Black GmbH"
}
...
It seems that the ‘in-between’ query “blackro” is what’s throwing things off, because it returns no results in the json object:
callback({
"companies": {"_total": 0},
"facets": {
"_total": 1,
"values": [{
"buckets": {"_total": 0},
"code": "location",
"name": "Location"
}]
},
"numResults": 0
})
My autocomplete code is long, but these are some of my settings:
dataType: 'jsonp',
jsonpCallback: "callback",
cache: true,
jsonp: false,
I’ve tried to wrap all of my code in a callback
function, but no success. Any ideas?
Originally posted 2013-12-02 20:56:37.