1

I'm using jQuery 1.10.2 and jQuery UI 1.11.4. My code:

HTML:

<input id="mats">

JavaScript:

var datasource = "asp/datasource_mats.asp";
//datasource = [{value:1,label:"name1"},{value:2,label:"name2"},{value:3,label:"name3"},{value:4,label:"name4"}];
$('#mats').autocomplete({
    source:datasource,
    minLength: 2,
    select: function(e,ui){
        alert("id: "+ui.item.value+" name: "+ui.item.label);
    }
});

ASP file (no matter whether ASP or PHP or other) is in the correct path and print this:

[{value:1,label:"name1"},{value:2,label:"name2"},{value:3,label:"name3"},{value:4,label:"name4"}]

If I uncomment the second JavaScript line, autocomplete work fine, but if widget try to read the data from the ASP file, it doesn't work, it doesn't show anything. Why? Really, the ASP file and the JavaScript variable return the same string.

According to this answer, my code should work, but not: jQuery UI autocomplete with JSON

Community
  • 1
  • 1

0 Answers0