Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Map data in jquery-ui autocomplete is not working
    primarykey
    data
    text
    <p>i am using jquery-ui autocomplete and making a ajax call inside the autocomplete function i am calling my controller action which returns Json , but suggestions is not showing in dropdown </p> <p><strong>Javascript</strong> </p> <pre><code> function log(message) { $("&lt;div&gt;").text(message).prependTo("#log"); $("#log").scrollTop(0); } $("#search").autocomplete({ source: function (request, response) { $.ajax({ url: "/Home/GetCompanyNames", dataType: "jsonp", data: "searchterm=" + request.term, success: function (data) { response($.map(data, function (item) { alert(item.Value); return { label: item.Name, value: item.Name }; })); } }); }, minLength: 2, select: function (event, ui) { log(ui.item ? "Selected: " + ui.item.label : "Nothing selected, input was " + this.value); }, open: function () { $(this).removeClass("ui-corner-all").addClass("ui-corner-top"); }, close: function () { $(this).removeClass("ui-corner-top").addClass("ui-corner-all"); } }); }); </code></pre> <p><strong>Action in Controller :</strong></p> <pre><code> public JsonResult GetCompanyNames (string searchterm) { var companies = context.companyService.Query().Where(x =&gt; x.Name.Contains(searchterm)).ToList(); var list = companies.Select(item =&gt; new SearchJsonModel { LogoUrl = item.Logo != null || item.Logo != "" ? "&lt;img src='/Upload/" + item.Logo + "' /&gt;" : "&lt;img src='/home/image?image=" + item.Name + "' /&gt;", Name = item.Name, Value = item.InternetName }).Select(model =&gt; (model)).ToList(); return Json(list, JsonRequestBehavior.AllowGet); } </code></pre> <p><strong>SearchJsonModel :</strong></p> <pre><code> public class SearchJsonModel { public string Name { get; set; } public string Value { get; set; } public string LogoUrl { get; set; } } </code></pre> <p><strong>and this is what i am getting in response of ajax call ( this is the image of firebug )</strong></p> <p><img src="https://i.stack.imgur.com/jronT.png" alt="enter image description here"></p> <p>Please ask me if you need more detail and thanks in advance . </p> <p><strong>Edit</strong></p> <p>now i am trying to access selected value in select callback but its giving <code>Undefined</code> </p> <pre><code>select: function (event, ui) { alert(ui.item.Name); alert(ui.item.Value); alert(ui.item.LogoUrl); }, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload