I am using WebApi to try and get json arry to my autocomplete jquery in my website,
I simpley need to trun a List into a auto complete object so i can show my clients a list of templates,
This is my Javascript Code -
<script>
var availableTags;
$.get(
"http://localhost:59040/api/Email/GetTemplates",
{ 'FirstName': "what she say", '': "sayhey" }, // put your parameters here
function (responseText) {
availableTags = responseText;
console.log(availableTags);
DoIt();
}
);
function DoIt(){
$(function () {
var ava = availableTags;
if (availableTags){
console.log("Its done")
$("#TemplatesAuto").autocomplete({
source: availableTags
});
}
else {
console.log("Not");
}
});
};
</script>
And my webapi Controller Code :
//Get templates
[HttpGet]//omUrl/{url?}
[Route(@"~/api/Email/GetTemplates")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public string GetTemplates()
{
List<string> Names = new List<string>();
Names.Add("Check");
Names.Add("Check");
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(Names);
}
Seems normal, works. BUT, when i try to write something in my autocomplete input, i get this error:
GET http://localhost:54662/Check/[%22Check%22,%22Check%22]?term=c 404 (Not Found)
I am getting crazy out here, looking for hours for the answer before coming here,
Please help.
Thanks alot, Good day :)
Aucun commentaire:
Enregistrer un commentaire