Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery-UI autocomplete is not working
    primarykey
    data
    text
    <p>I need using jQuery-ui "autocomplete" in an .net MVC program, but it is not working. Anybody can help me out will be great appreciated. </p> <p>The view code is like below:</p> <pre><code>&lt;head runat="server"&gt; &lt;link href="../../Content/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="../../Scripts/jquery-1.6.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jquery-ui-1.8.14.custom.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;script type="text/ecmascript"&gt; $(document).ready(function () { $.ajax({ type: "GET", url: "/Product/GetProductName/", dataType: "json", data: { categoryID: &lt;%: Model.Select(o =&gt; o.Category.CategoryName).Distinct().Count() &gt; 1 ? 0 : Model.FirstOrDefault().CategoryID %&gt; }, contentType: "application/json; charset=utf-8", success: function(data) { $('#productNameSearch').autocomplete({ minLength: 0, source: Sys.Serialization.JavaScriptSerializer.deserialize(data), focus: function(event, ui) { $('#productNameSearch').val(ui.item.ProductName); return false; }, select: function(event, ui) { $('#productNameSearch').val(ui.item.ProductName); $('#selectedValue').text("Selected value:" + ui.item.ProductID); return false; } }); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }); &lt;/script&gt; &lt;% using (Html.BeginForm("ProductNameSearch", "Product", FormMethod.Post)) {%&gt; &lt;input type="text" id="productNameSearch" name="productNameSearch" style="width:300px" /&gt;&amp;nbsp; &lt;input type="submit" value="Go!" /&gt; &lt;div id="selectedValue"&gt;&lt;/div&gt; &lt;%}%&gt; </code></pre> <p>The controller code is like below:</p> <pre><code>[HttpGet] public ActionResult GetProductName(int? categoryID) { return Json(from p in pr.GetProductList() where p.CategoryID == 2 select new { ProductID = p.ProductID, ProductName = p.ProductName }, JsonRequestBehavior.AllowGet); } </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.
 

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