easyui中ajax笔记

来源:互联网 发布:hifi音频播放软件 编辑:程序博客网 时间:2024/06/09 21:28
//文件上传按钮点击事件$("#onupload").click(function(){$("#file").attr("value","");//清空file域$("#uploadfile").window("open");});$("#tjwhsaveFile").unbind('click').click(function(){防止ajax重复提交表单,所以给点击事件unbind//上传文件$("#saveFile").click(function(){$("#uploadform").ajaxSubmit({type:"post",url:"fileuploadAction.action",data: $(this).serialize(),dataType: 'json',//设置返回的数据库类型为jsonsuccess:function(result){//result和data一样都是返回的数据if(result[0].success){$.messager.alert('提示', result[0].msg, 'warning');$('#uploadfile').window('close');createfileTable();loadData(path+'/filegetfileAction.action','file_info_datagrid', null);}else{$.messager.alert('提示', result[0].msg, 'warning');$("#file").attr("value","");//清空file域}}});return false;}); <a href="javascript:void(0);" onclick="delete())">删除</a><script type="text/javascript">    function delete(){         if(confirm("确定要删除吗?")){             $.ajax({                url: '${contextPath}/system/delMessage.do',                data: 'id=' + id,                type: 'POST',                dataType: 'text',                success: function(responseText){                    if(responseText == 'true'){                        alert('删除成功');                    }else {                        alert('删除失败');                    }                    location.reload();                }            });        }     }</script>formatter : function(value,row,index) {//return "<a href='filepreviewAction.action?filePo.fileid="+row.fileid+"&filePo.filename="+row.filename+"' target='_blank'>在线预览</a>";return "<a href='javascript:void(0);' fileid='"+row.fileid+"' filename='"+row.filename+"' onclick='preview(this)'>在线预览</a>";}清空combobox  $("#agender").combobox('clear');  默认让combobox选中 $("#agender").combobox('select',row[0].gender);获取combobox的值$('#agender').combobox('getValue') $.trim($('#bgender').combobox('getValue'));电话验证正则表达式<script type="text/javascript"> //自定义验证  $.extend($.fn.validatebox.defaults.rules, {  phoneRex: {    validator: function(value){    var rex=/^1[3-8]+\d{9}$/;    //var rex=/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;    //区号:前面一个0,后面跟2-3位数字 : 0\d{2,3}    //电话号码:7-8位数字: \d{7,8    //分机号:一般都是3位数字: \d{3,}     //这样连接起来就是验证电话的正则表达式了:/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/     var rex2=/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;    if(rex.test(value)||rex2.test(value))    {      // alert('t'+value);      return true;    }else    {     //alert('false '+value);       return false;    }          },    message: '请输入正确电话或手机格式'  }});</script><td>联系电话:<input style="width: 120px; border: 1px solid #999;"id="arelationMobileNumber" class="easyui-validatebox" data-options="validType:'phoneRex'"/><!-- id="arelationMobileNumber" class="easyui-validatebox" validType="phone"/> --><!-- id="arelationMobileNumber"/> --></td>$("#aunitCode option[value='"+row[0].unitCode+"']").attr("selected", "selected"); 纯jquery给下拉框赋值,非easyui$('#interfacesNone').datagrid('clearSelections');easyui清空checkboxfunction(data){$.messager.alert('消息',"修改成功",'info');$('#file_info_datagrid').datagrid('clearSelections');loadData(path+'/filegetfileAction.action','file_info_datagrid', null);},'json'//清空下拉框$("#tjwhunitcodes option[value='']").attr("selected", "selected");$("#tjwhunitcodes option:first").text();$("#tjwhunitcodes").empty();

0 0
原创粉丝点击