Skip to content

Commit 171744b

Browse files
committed
support response being an object (after jquery default parsing) and passing jsonp as a dataType in addition to string type
1 parent 5619531 commit 171744b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/jquery.autocomplete.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
onSearchComplete: noop,
9090
containerClass: 'autocomplete-suggestions',
9191
tabDisabled: false,
92+
dataType : 'text',
9293
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
9394
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
9495
},
@@ -406,7 +407,7 @@
406407
url: options.serviceUrl,
407408
data: options.params,
408409
type: options.type,
409-
dataType: 'text'
410+
dataType: options.dataType
410411
}).done(function (txt) {
411412
that.processResponse(txt);
412413
options.onSearchComplete.call(that.element, q);
@@ -476,7 +477,7 @@
476477

477478
processResponse: function (text) {
478479
var that = this,
479-
response = $.parseJSON(text);
480+
response = typeof text == 'string' ? $.parseJSON(text) : text;
480481

481482
response.suggestions = that.verifySuggestionsFormat(that.options.transformResult(response));
482483

0 commit comments

Comments
 (0)