Reputation: 2275
I'm modifying BSN's Autosuggest script so it will work with codeigniter, the only proble is I cant seem to figure out why it displays "missing ) in parenthetical" says the problem is around else
_b.AutoSuggest.prototype.setSuggestions = function (req, input) {
if (input != this.fld.value) return false;
this.aSug = [];
if (this.oP.json) {
var jsondata = eval('(' + req.responseText + ')');
for (var i = 0; i < jsondata.results.length; i++) {
this.aSug.push({
'id': jsondata.results[i].id,
'value': jsondata.results[i].value,
'info': jsondata.results[i].info
});
}
} else {
var xml = req.responseXML;
// traverse xml
//
var results = xml.getElementsByTagName('results')[0].childNodes;
for (var i = 0; i < results.length; i++) {
if (results[i].hasChildNodes()) this.aSug.push({
'id': results[i].getAttribute('id'),
'value': results[i].childNodes[0].nodeValue,
'info': results[i].getAttribute('info')
});
}
}
this.idAs = "as_" + this.fld.id;
this.createList(this.aSug);
};
Any help would be appreciated, i'm not very good at JS
Upvotes: 1
Views: 5859
Reputation: 207501
The output of the server is invalid. Look at the responseText that is being returned with either Fiddler or Firebug. It is most likely something being injected into the response that should not be there.
Also if you are using jQuery, change the code to use their ajax methods.
Upvotes: 2