<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>ϞҪ͢τյ</title> <script src="jquery-203.js"></script> </head> <body> <script> window.onload = function(){ $.param({'aa':1,'bbb':2});//aa=1&&bb=2 $.param({'aa':汉字,'bbb':2});//aa=编码&&bb=2 $.param({'aa':[1,3],'bbb':2},); $.param( [ {'name':1,'value':2} ] );//1=2,name为key,value为value $.param( [ {'name':1,'value':2},{'name':3,'value':4} ] );//1=2,name为key,value为value var $a = $( [ {'name':1,'value':2},{'name':3,'value':4} ] ) }; console.log( $.param($a) ) </script> </head> <body> <div id="div1" style="MozTranfroms" width="100px" text-align="left">aaaaaaaaaaaa</div> </body> </html>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>sss</title> <script src="jquery-203.js"></script> </head> <body> <script> window.onload = function(){ console.log($('#form1').serialize());//a=1&b=2 console.log($('#form1').serializeArray());//[{'name':'a','value':'1'},{'name':'b','value':'2'}] $('#form1').get(0).elements;//表单所有属性,只有表单有elements属性。elements属性是原生js对象才有的属性。 $('#div1').load('1.html');//div里面加载1.html页面, $('#div1').load('1.html ol',function(a,b,c){ console.log(a);//返回的页面 console.log(b);//success console.log(c);//xml response对象 alert("加载完成"); });//div里面加载1.html页面里面的ol标签,完成后回调 $('#div1').load("1.html ol,{'name':'hello'}",function(a,b,c){ console.log(a);//返回的页面 console.log(b);//success console.log(c);//xml response对象 alert("加载完成"); });//div里面加载1.html页面里面的ol标签,完成后回调 $.ajax({ url:url, success : function(){} error: }).done(function(){}).fail(function(){}); $.get('url',{'aa':123},function(){'成功回调'},'返回数据类型xml、json') $.getScript( 'url',function(){} ) $.getJSON( 'url',function(){} ) $.ajax({ type:'post',//默认get url:url, cache:false, //请求后面加一个时间戳,不会有缓存 success : function(){} error:function(){} }); $.ajax('url',{ type:'post',//默认get success : function(){} error:function(){} }); $.ajax({ url:url, timeout:1000, //一秒钟没有请求成功就报错 type:'post', success : function(){alert(1)}, error:function(){alert(2)}, statusCode:{ 404:function(){ alert(); } } }); } </script> </head> <body> <form id="form1"> <input name="a" value="1"> <input name="b" value="2"> <input type="submit"> </form> <div id="div1"></div> </body> </html>