juqery运用随笔
juqery应用随笔
//Jquery实现
JS代码:
//先加入
<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>包
//action的代码如下
//显示加载图标的DIV
//Jquery实现
JS代码:
//先加入
<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>包
//AJAX调用更新网站的方法 function updateChannelPages(update_ch_id,update_ch_name){ $.ajax({ type: "post", url: "admin_Channel_updateChannelPage.action?update_ch_id="+update_ch_id, datatype:"json", async:false, success: function(data){ if(data=="0") { $("#msg").html("更新<"+update_ch_name+">栏目失败,请重新操作!"); } else { $("#msg").html("更新"+update_ch_name+"栏目成功!"); } } }); $("#loading").ajaxStart(function(){$(this).css("display", "block");});//用于显示加载图标 $("#loading").ajaxSuccess(function(){$(this).css("display", "none");}); }
//action的代码如下
/** * 方法描述:AJAX更新栏目信息的方法 * @throws Exception */ public void updateChannelPage() throws Exception { String flagString=""; PrintWriter out = ServletActionContext.getResponse().getWriter(); try { String id = this.update_ch_id; channel = this.channelService.getChannelByPk(id); ParseHtml pHtml=new ParseHtml(); pHtml.doIndexHtml(channel.getTemp_path(), channel.getFile_name(), channel.getSave_dir()); flagString="1"; } catch (Exception e) { e.printStackTrace(); flagString="0"; } out.write(flagString);//返回值 }
//显示加载图标的DIV
<div id="loading" style="display:none; position:absolute; left:438px; top:215px;"> <img src=/manager/admin/images/upLoading.gif style="width:45px; height:40px;"> 更新中... </div>