JQuery serialize后,在后台取不到值的问题
来源:互联网 发布:银行叫号系统c语言 编辑:程序博客网 时间:2024/04/27 23:43
在使用JQuery的AutoComplete功能时,出现一个奇怪的问题,那就是后台取不到被serialize后的form中的input的值。为这个问题烦恼了n久,终于找到原因。原因很汗。。。那就是被serialize的form被嵌套在了另外一个form中。目前只是知道如何修改,至于原因,暂时不考虑,留待有空验证。顺便记录一下JQueryAutoComplete的用法(框架是Thinkphp3.2)。
前台:
<html>
<head>
</head>
<body>
<link href="__PUBLIC__/Home/jquery-ui/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
<script src="__PUBLIC__/Home/jquery-1.7.1.min.js"></script>
<script src="__PUBLIC__/Home/jquery-ui/js/jquery-ui-1.8.17.custom.min.js"></script>
<script src="__PUBLIC__/Home/jquery-ui/js/jquery-ui-widget-combobox.js"></script>
<script type="text/javascript">
//getgoodstrend ajax end
var Auto = $.noConflict(); //使用了AmazeUI的前段框架,里面也引用了另外一个版本的JQuery,此处意思是让JQuery知道用了两个库,他会去找最合适的库,不会出现方法不存在的问题
//auto complete start
Auto(function() {
Auto("#goodsidtoadd").autocomplete({
source:function( request, response ) {
Auto.ajax({
url: "__URL__/searchgoodstoaddbyajax",
dataType: "json",
data:$('#addgoodsform').serialize(),
success: function( result ) {
response( Auto.map( result, function( item ) {
return item;
}));
}
});
}
});
});
//auto complete end
</script>
<form name="addgoodsform" accept-charset="utf-8" id="addgoodsform" method="post">
<div class="am-u-sm-2">药品名称:</div>
<input type="text" name="goodsidtoadd" id="goodsidtoadd" placeholder="药品名称" class="am-form-field">
</div>
</form>
</body>
</html>
后台:
public function searchgoodstoaddbyajax()
{
$SICK = M("sickness");
$queryStr = "name LIKE '%".I("get.goodsidtoadd")."%' OR id LIKE '%".I("get.goodsidtoadd")."%'";
$sicklist = $SICK->where($queryStr)->select();
$index = 0;
foreach ($sicklist as $sick) {
$json[$index]['label']=$sick['name'];
$json[$index]['value']=$sick['id'];
$index++;
}
if(empty($json))
{
$json[0]['label']="无对应病症";
$json[0]['value']="";
}
$this->ajaxReturn($json,'JSON');
/*
$CON = M("vipconsumption");
$queryStr = "goodsname LIKE '%".I("get.searchinfo")."%' OR goodscode LIKE '%".I("get.searchinfo")."%'";
$conlist = $CON->where($queryStr)->group("goodscode")->field("goodscode,goodsname")->limit(10)->select();
$index = 0;
foreach ($conlist as $con) {
$json[$index]['label']=$con['goodsname'];
$json[$index]['value']=$con['goodscode'];
$index++;
}
if(empty($json))
{
$json[0]['label']="无对应药品";
$json[0]['value']="";
}
$this->ajaxReturn($json,'JSON');
*/
}
效果
- JQuery serialize后,在后台取不到值的问题
- ID和Name的问题------写个<input type="hidden">在后台取不到值
- textbox 设置enabled=false 或是readonly=true 后,在后台无法取值的问题
- servlet在后台获取不到值的原因
- Javascript动态添加文本输入框在后台无法取值问题的解决
- struts2 数据传输问题---“POST方式提交数据量过大,在后台接收不到数据”问题的解决
- 在Javascript 中给label控件的 innerHTML 赋值,在后台获取不到 text值
- (小技巧)解决JS修改服务器控件值在后台无法获取修改后的值的问题
- 在后台取前台Div或Table的innerHTML或innerText问题
- [VBA]在后台删除工作表后出现的怪问题
- dropdownlist取不到值的问题!!
- Filter过滤器,取不到值的问题!
- onActivityResult 取不到返回值的问题
- session取不到值的问题
- ASP.NET----GridView多种用法,以及在后台取对应列的值
- struts在后台取动态添加的数值,getParameterValues
- sturt1 submit 提交在后台回去不到表单的值,是否加了disabled="true "属性?
- 让程序退出后在后台运行的方法
- 欢迎使用CSDN-markdown编辑器
- 按钮的添加
- 使用Visual studio调试其他编译工具编译好的程序
- 3sum
- HTCVive 手柄圆盘按钮角度计算
- JQuery serialize后,在后台取不到值的问题
- windows下启动关闭oracle
- Maven Dependency设置,详解!
- java 多线程总结(一) 创建线程的几种方法及对终止线程运行的讨论
- 《selenium2 自动化测试实战》
- 在windows上下载安装Android sdk
- 添加子视图
- Linux下Postfix的安装与配置(未完待续)
- POJ 3107 Godfather