I've created an array using php which I've then json encoded
$json_array = json_encode($newarray);
In my jquery, the encoded array seems to be formed OK (i think??) but when I try and use the json data - nothing happens? I'm expecting the textbox to autocomplete.
The funny thing is - it works if I use arraytxt2, but not arraytxt1 (the one created via json_encode).
Any ideas as to why arraytxt1 is not working?? Thanks in advance.
$(document).ready(function () {
var arraytxt1 = [{
"equipmentid": "1",
"equipmentmake": "Baxi"
}, {
"equipmentid": "2",
"equipmentmake": "Baxi"
}];
var arraytxt2 = [{
"id": "1",
"label": "aa"
}, {
"id": "2",
"label": "bb"
}, {
"id": "3",
"label": "bbbb"
}, {
"id": "4",
"label": "abab"
}, {
"id": "5",
"label": "cab"
}];
$("#txt1").autocomplete({
source: arraytxt1,
minLength: 1,
select: function (event, ui) {
$("#txt2").val(ui.item.equipmentid);
}
});
});