首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

JQuery 中action简略跳转运用

2012-07-23 
JQuery 中action简单跳转运用1.应用attr为action添加属性值?? $(#btn_submitall_inquiry).click(functio

JQuery 中action简单跳转运用

1.应用attr为action添加属性值

?? $("#btn_submitall_inquiry").click(function(){
??? ???
??? var newAction = V_Context_Path + "admin/cg_submitallnewinquiry";
??? var frm = $("#frm_inquiry_list");
??? var oldAction = frm.attr("action");
??? ???
??? frm.attr("action", newAction);
??? frm.submit();
??? ???
??? frm.attr("targer","");
??? frm.removeAttr("target");
??? frm.attr("action",oldAction);
??? ???
??? return false;
?});

这种情况如果要求页面自动刷新,在配置struts.xml中的action的result返回值type设置为chain,后面跟action。

?

2.应用ajax

?

$("#btn_change_2_orderes").click(function(){
??? ???
??? ??? var link = "admin/cg_inquiry2orderes";
??? ??? var datas = "idLists=" + idLists+"&orderId" = "orderId";
??? ???
??? ??? $.ajax({
??? ??? ??? type: "post",
??? ??? ??? cache : false,
??? ??? ??? url: V_Context_Path + link,
??? ??? ??? data: datas,
??? ??? ??? error: function(xhr, error, msg){
??? ??? ??? },??? ??? ???
??? ??? ??? success: function(data){
??? ??? ??? ??? var arr = data.split(":");
??? ??? ??? ??? var f = arr[0];
??? ??? ??? ??? var s = arr[1];
??? ??? ??? ??? if(f=="warn"){
??? ??? ??? ??? ??? alert(s);
??? ??? ??? ??? }
??? ??? ??? ??? else if(f=="success"){
??? ??? ??? ??? ??? alert(s);
??? ??? ??? ??? ??? window.location.href = window.location.href;
??? ??? ??? ??? }
??? ??? ??? ??? else{
??? ??? ??? ??? }???
??? ??? ??? }??? ??? ??? ??? ??? ???
??? ??? });
??? });

link: ? ? 链接Action的name;

datas: 需要传递给Action的参数

在返回值中:

?? sRet = "warn:该询报价供应商 " + ii.getItemSuppliername() + " 还没有提交报价单!";

??? sRet = "success:询价单转换成采购订单成功";

热点排行