jquery积累

重置表单内容

$('#menu_menuForm').resetForm();

 

获得Object的两种方法

$("input[name='departTypeVO.name']").val(departType_depTypeSelect['name']);

$("input[name='departTypeVO.name']").val(departType_depTypeSelect.name);

//防止名称保留字

 

Ajax弹出确认窗

varflag=confirm("确定要删除"+menu_menuNodeSelect.name+"吗?");

if(flag==true){}

else{}

 

each遍历ObjectArray

1.object

$.each(data,function(key,value){

alert(“key= ”+key +”;value=”+value);

});

2.array

  $.each(data,function(i,item){

      alert(“index= ”+i +”;item_object= ”+ item);              

   });

 

Ajax的数据提交方式

1.通过data传值   (当dataType为dataType:"json"时 返回的是String  当dataTypr为dataType:"json"时 返回的是JsonObject)

$.ajax({

                type:"get",

                dataType:"json",

                cache:false,

               data:{"name1":data1 ,

"name2":data2},

url:"${pageContext.request.contextPath}/common/user_getUserByDepart.action",

                success:function(data){

                    //清空表格数据

                    user_userTable.fnClearTable();

                    //添加用户数据

                    if (objectNotNull(data))

                       addTableRow(user_userTable, data);

                      

                }              

         });

 

2.通过(?&) 传值

$.ajax({

                type:"get",

                dataType:"json",

    cache:false,              url:"${pageContext.request.contextPath}/common/user_getUserByDepart.action?name1="+data1+"name2="+data2,

                success:function(data){

                    //清空表格数据

                    user_userTable.fnClearTable();

                    //添加用户数据

                    if (objectNotNull(data))

                       addTableRow(user_userTable, data);

                      

                }              

         });

 

2.Ajax相应点击事件提交(含有error的检测)

$(".logout-button").click(function(event)

{

    // stop the contact form from submitting normally

    event.preventDefault();

 

    $.ajax(

    {

        url: "/?ACT=79&return=%2F",

        type: "post",

        dataType: "html",          

        data: $(this).serialize(),

 

        // there was an error

        error: function(jqXHR, textStatus, errorThrown)

        {

            displayAjaxMessage("Sorry, there was an error logging out, please try again.");

        },

 

        success: function(html, textStatus, jqXHR)

        {

            $("#login-form").show();

            $(".logout-button").hide();

            displayAjaxMessage("<p>You are now logged out</p>");

        }

 

    });

});

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值