亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Ajax ?? ??

Ajax ?? ??

jQuery? Ajax ??? ???? ? ?? ?? ??? ?????.

1. jQuery.ajaxSetup( ?? )

?? ? ??

??:

?? AJAX ?? ?? ??? ?????.

??:

??? ???? ?? Ajax ??? ?? ??? ????? ?? ? ??? ???? ??? ??? ? ??? ??? ?? Ajax ??? ?? ??? ?????.

?? ?? ???? ???? ?? ??? ???? Ajax? ?? ??? ?????.

$.ajaxSetup({    url: "../data/AjaxGetMethod.aspx",    data: { "param": "ziqiu.zhang" },    global: false,    type: "POST",    success: function(data, textStatus) { $("#divResult").html(data); }});
此后我們可以使用無參數(shù)的get(),post()或者ajax()方法發(fā)送 ajax 請求.完整的示例代碼如下:
<!doctype html><html><head>
 <meta charset="utf-8"/>
 <title>jQuery Ajax - Load</title>
 <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
 <script>
   $(document).ready(function() {
     $.ajaxSetup({
         url: "../data/AjaxGetMethod.aspx",
         data: { "param": "ziqiu.zhang" },
         global: false,
         type: "POST",
         success: function(data, textStatus) {
           $("#divResult").html(data);
         }
     });
     $("#btnAjax").click(function(event) { $.ajax(); });
     $("#btnGet").click(function(event) { $.get(); });
     $("#btnPost").click(function(event) { $.post(); });
     $("#btnGet2").click(function(event) { $.get("../data/AjaxGetMethod.aspx",{ "param": "other" }); });
   });  </script></head>  <body>    
 <button id="btnAjax">nontransfer param call ajax() method</button><br />
 <button id="btnGet">nontransfer param call get() method</button><br />
 <button id="btnPost">nontransfer param call post() method</button><br />
 <button id="btnGet2">transfer param call get() method , use global default callback</button><br />
 <br />
 <div id="divResult"></div>
</body>
</html>

get() ?? post() ???? ??? ? type ????? GET?? ?? ????? ?? ?????. ?? POST, ?? ????? ???? ?? ? ?? ?? ??? ?????. ?? ?? ??? ??? URL? ????? ???? ? ?? ??? ???? ? ??? ??? ??? ???? ???. ?? ??? ?? ???? ?? ??? ??? ???? ??? ???? ?? ?????.

2.serialize( )

??: String

??:

?? ?? ???? ???? Ajax ??? ???? ??????.

???? ?? ???? ??? ?? ? ?? ????? ?????. ???? ???? ?? ???? ?? ?? ???? ??? ? ????.

??? ????? ????? ????? ?? ??? ?? ??? ??? ??? ???.

name ??? ??? ?? ?????. <input id="email" name="email" type="text" />

??:

serialize() ??? ?? ??? ??? ?????. ???? ??? ?????. Ajax? ???? ?? ? ?? ???? ?? ?? ?????. ?? Get ???? ?? ??? ??? ? ?? ??? ??/?? ???? ?? URL? ???? ?? ?????.

3.serializeArray( )

Returns: Array< Object>

??:

JSON ??? ???? ? ??? ????? jQuery? JSON ??? JSON ???? ???? ??? ???? ????. . ??? ?? ??


?? ??? jquery.json ????? ?? ????? ???? ???.
???? ??
||
<html> <head> <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("div").text($("form").serialize()); }); }); </script> </head> <body> <form action=""> 姓名: <input type="text" name="FirstName" value="Bill" /><br /> 職位: <input type="text" name="LastName" value="Gates" /><br /> </form> <button>序列化表單值</button> <div></div> </body> </html>