jQuery autocomplete works with a local string but not when the same String is called off the server
- by Ankur
This is related to the question I asked at http://stackoverflow.com/questions/2802948/how-to-make-an-ajax-call-immediately-on-document-loading
My code is:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "../AutoComplete",
success: function(data) {
var dataArray = data;
alert(dataArray);
$("#example").autocomplete(dataArray);
}
});
});
The value that is printed in the alert is:
"Manuscript|Text|Information Object|Basketball|Ball|Sporting Equipment|Tarantula|Spider|Australian Spider|Cricket Player|Medieval Artefact|Person|Sportsperson|Leonardo Da Vinci|Country|Language|Inventor|Priest|Electronics Manufacturer|Object|letter|Artefact|governance model|Organism|Animal".split("|");
If instead I do this:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "../AutoComplete",
success: function(data) {
var dataArray = "Manuscript|Text|Information Object|Basketball|Ball|Sporting Equipment|Tarantula|Spider|Australian Spider|Cricket Player|Medieval Artefact|Person|Sportsperson|Leonardo Da Vinci|Country|Language|Inventor|Priest|Electronics Manufacturer|Object|letter|Artefact|governance model|Organism|Animal".split("|");
alert(dataArray);
$("#example").autocomplete(dataArray);
}
});
});
It works fine?