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("

You are now logged out

");

        }

 

    });

});

 

 

你可能感兴趣的:(jqurey)