(072)jquery_异步_ajaxSetup
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>ajax_ajaxSetup.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <style type="text/css"> #divtest { width: 282px; } #divtest .title { padding: 8px; background-color:Blue; color:#fff; height: 23px; line-height: 23px; font-size: 15px; font-weight: bold; } ul { float: left; width: 280px; padding: 5px 0px; margin: 0px; font-size: 14px; list-style-type: none; } ul li { float: left; width: 280px; height: 23px; line-height: 23px; padding: 3px 8px; } .fl { float: left; } .fr { float: right; } </style> <script type="text/javascript" src="../js/jquery/jquery190.js"></script> <script type="text/javascript"> $(function(){ $.ajaxSetup({ dataType:"text", success:function(data){ $("#resultDiv").html(data); }, type:"post" }); $("#btnShow_1").bind("click",function(){ $.ajax({ data:{number:$("#txtNumber").val()}, url:"http://localhost:9090/JQuery/servlet/AjaxSetupServlet1" }); }); $("#btnShow_2").bind("click",function(){ $.ajax({ data:{number:$("#txtNumber").val()}, url:"http://localhost:9090/JQuery/servlet/AjaxSetupServlet2" }); }); }); </script> </head> <body> <div id="divtest"> <div class="title"> <span class="fl">奇偶性和是否大于0</span> <span class="fr"> <input id="btnShow_1" type="button" value="验证1" /> <input id="btnShow_2" type="button" value="验证2" /> </span> </div> <ul> <li>请求输入一个数字 <input id="txtNumber" type="text" size="12" /> </li> </ul> </div> <div id="resultDiv"></div> </body> </html>
使用ajaxSetup()方法可以设置Ajax请求的一些全局性选项值,设置完成后,后面的Ajax请求将不需要再添加这些选项值,它的调用格式为:
jQuery.ajaxSetup([options])或$.ajaxSetup([options])
***万事万物都有裂痕,那是光照进来的地方***

浙公网安备 33010602011771号