I am trying to use Tag-It plugin for tags on my blog, but I have encountered a problem. My autocompletion is not working, if I use available tags option it completes just fine, but if i try to use Ajax nothing happens, or atleast on client side. My method triggers and returns right data but nothing is whispered. Script:
$("#tag_input").tagit({
// Options
fieldName: "skills",
availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"],
autocomplete: {
source: function( request, response ) {
$.ajax( {
url: "@Url.Action("SearchTags", "Post")",
dataType: "jsonp",
data: {
query: request.term
},
success: function( data ) {
response(data);
}
} );
},
minLength: 3,
} ,
My function in controller:
public JsonResult SearchTags(string query)
{
TagDao td = new TagDao();
List<String> tags= td.getTagNames(query);
return Json(tags, JsonRequestBehavior.AllowGet);
}
If someone is interested in solution, it was caused by "jsonp" type. When i used only "json" it is working just fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.