Friday, December 30, 2011

jQuery UI Autocomplete: problem solved

It seems that in programming, often the simplest issues cause the most wasted time. Most of yesterday was spent trying to integrate the jQuery UI Autocomplete component into a project. I could tell it was contacting the target file on the server, but it would never return any matches.

Today, I opened the Firebug console and noted that despite getting a 200 OK message on the request, the response pane was always empty. A Google search turned up a discussion on StackOverflow that described my predicament exactly.

In reviewing my code, I found that my source parameter in the Autocomplete function code pointed to an absolute URL beginning with http://. Evidently this caused the ajax code to fail on the presumption it was pointing to an external domain (though the target file was actually on the same domain). By changing it to a site-root relative URL, my autocomplete component works.

No comments:

Post a Comment