本文介绍了J Query将Null值传递给Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个

i为自动完成文本框获取一个jquery,后面的查询只将空值传递给控制器​​。如果你能帮我解决这个问题,那将是一个很大的帮助!



输入id =searchTermname =searchTerm1type =text/>& nbsp; 

< script type =text / javascript>
$(function(){
$(#searchTerm)。autocomplete({
source:/ Home / AutocompleteSuggestions,
minLength:1,
select:function(event,ol){
if(ol.item){
$(#searchTerm)。val(ol.item.value);
$(form1 ).submit();
}
}
});
});
< / script>


//在控制器类中

public JsonResult AutocompleteSuggestions(string ss)
{
var suggestions = selectEmployees.getEmployeeSuggestedNames(ss) ;
返回Json(建议,JsonRequestBehavior.AllowGet);
}
解决方案




hi every one
i get a jquery for the Auto completion textbox and following query only pass null values to the controller .if you could assist me on this matter that would be a great help!!!

input id="searchTerm" name="searchTerm1" type="text" />&nbsp;

     <script type="text/javascript">
         $(function () {
             $("#searchTerm").autocomplete({   
                 source: "/Home/AutocompleteSuggestions",
                 minLength: 1,
                 select: function (event, ol) {
                     if (ol.item) {
                         $("#searchTerm").val(ol.item.value);
                         $("form1").submit();
                     }
                 }
             });
         });
    </script>


//in controller class

 public JsonResult AutocompleteSuggestions(string ss)
        {
            var suggestions = selectEmployees.getEmployeeSuggestedNames(ss);
            return Json(suggestions, JsonRequestBehavior.AllowGet);
        }
解决方案




这篇关于J Query将Null值传递给Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 21:09