Asp.Net MVC3 JQuery自动完成JSON响应没有填充框 [英] Asp.Net MVC3 JQuery Autocomplete JSON response does not fill the box

查看:60
本文介绍了Asp.Net MVC3 JQuery自动完成JSON响应没有填充框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



今天是我的休息日,所以我想花一些时间在jquery ui上。首先,我使用了ready函数。现在我在一个我正在开发的项目中尝试这个。



简单地说,有一个用于搜索的文本框。

我的DDataController

 DDataBLL _data =  new  DDataBLL(); 
public ActionResult Ara()
{
return 查看() ;
}

public ActionResult AraJSON( string term)
{
var data = _data.SelectAll()。其中​​(x = > x.Icerik.Contains(术语));
return Json(data,JsonRequestBehavior.AllowGet);
}





和我的观点

 @ {
ViewBag.Title =Ara;
Layout =〜/ Views / Shared / _Layout.cshtml;
} @model IEnumerable < JQueryAutoComplete.Models.DData >
< h2 >
jQuery Ui自动填充< / h2 < span class =code-keyword>>
< script src = @ Url.Content( 〜/ Scripts / jquery-ui-1.8.11.min.js) 类型 = text / javascript > < / script >
< link < span class =code-attribute> href = @ Url.Content( 〜/ Content / themes / base / jquery.ui.all.css) rel = stylesheet 类型 = text / css / >
< script type = text / javascript >
$( function (){
$( #deger)。autocomplete({
source: / DData / AraJSON
minLength: 1
});
});
< / script >
< div class = 演示 >
< div class = ui-widget >
< label for = deger >
Birdeğergirin:
< / label >
< 输入 id = < span class =code-keyword> deger
size = 50 / >
< / div >
< / div >





localproject / araJSON ?term = a请求响应用户请求JSON的确切数据。这里没问题。但是,localproject / ara链接不会填充文本框下的JSON数据。如果存在数据,则文本框下方会出现一个没有文本的小框。我错过了什么?

解决方案

function (){


< blockquote>( #deger)。autocomplete({
source: / DData / AraJSON
minLength: 1
});
});
< / script >
< div class = 演示 >
< div class = ui-widget >
< label for = deger >
Birdeğergirin:
< / label >
< 输入 id = < span class =code-keyword> deger size = 50 / >
< / div >
< / div >





localproject / araJSON ?term = a请求响应用户请求JSON的确切数据。这里没问题。但是,localproject / ara链接不会填充文本框下的JSON数据。如果存在数据,则文本框下方会出现一个没有文本的小框。我错过了什么?


Hello everyone,

today is my off day, so I wanted to spend some time on jquery ui. First I used the ready functions. Now I am trying this in a project that I'm already developing.

Simply, there is a textbox that is used to search.
My DDataController

DDataBLL _data = new DDataBLL();
 public ActionResult Ara()
        {
            return View();
        }

        public ActionResult AraJSON(string term)
        {
            var data = _data.SelectAll().Where(x => x.Icerik.Contains(term));
            return Json(data, JsonRequestBehavior.AllowGet);
        }



And My view

@{
    ViewBag.Title = "Ara";
    Layout = "~/Views/Shared/_Layout.cshtml";
}@model IEnumerable<JQueryAutoComplete.Models.DData>
<h2>
    jQuery Ui Autocomplete</h2>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function () {
        $("#deger").autocomplete({
            source: "/DData/AraJSON",
            minLength: 1,
        });
    });
</script>
<div class="demo">
    <div class="ui-widget">
        <label for="deger">
            Bir değer girin:
        </label>
        <input id="deger" size="50" />
    </div>
</div>



localproject/araJSON?term=a that request responses the exact data what the user request as JSON. No problem here. However, localproject/ara link does not fill the JSON data under the textbox. If data exists, a little box appear under the textbox with no text. What am I missing?

解决方案

(function () {


("#deger").autocomplete({ source: "/DData/AraJSON", minLength: 1, }); }); </script> <div class="demo"> <div class="ui-widget"> <label for="deger"> Bir değer girin: </label> <input id="deger" size="50" /> </div> </div>



localproject/araJSON?term=a that request responses the exact data what the user request as JSON. No problem here. However, localproject/ara link does not fill the JSON data under the textbox. If data exists, a little box appear under the textbox with no text. What am I missing?


这篇关于Asp.Net MVC3 JQuery自动完成JSON响应没有填充框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆