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

jQuery - AJAX ?? ? ??

jQuery - AJAX ??

AJAX? ??????

AJAX = ??? JavaScript ? XML.

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

jQuery ? AJAX ??

jQuery? AJAX? ??? ?? ???? ?????.

jQuery AJAX ???? ???? HTTP Get ? HTTP Post? ???? ?? ???? ???, HTML, XML ?? JSON? ??? ? ???, ? ?? ???? ? ???? ??? ??? ?? ??? ? ????.

AJAX ?????? jQuery? ??? ??? ?? ?????.

?? AJAX ??? ???? ?? ?????? AJAX? ??? ???? ??? ?? ????. ?, ????? ?????? ?? ??? ???? ???. ??? jQuery ?? AJAX ??? ???? ? ??? ?? ?? ??? ? ??? ??????.

AJAX load() ???

jquery load() ???? jquery ajax? non-refresh ??? ? ??? ???? ??? ??? ID? ?? ??? ? ???, ????? ???? ?? ?? ?? ????. .????? load()? ? ?? ???? ???? ??? ???????.

??:

$(selector).load(URL,data,callback);

?? URL ????? ????? URL? ?????.

??? ??? ????? ??? ?? ??? ?? ??? ?/? ? ??? ?????.

???? ?? ????? load() ???? ??? ? ???? ??? ?????.

?:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src=" 
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("");});
});
</script>
</head>
<body>
<div id="div1">
<h2>使用 jQuery AJAX 修改文本內(nèi)容</h2>
</div>
<button>獲取外部內(nèi)容</button>
</body>
</html>

URL ????? jQuery ???? ??? ?? ????.

?? ???? "demo_test.txt" ???? id="p1"? ??? ???? ??? <div> ??? ?????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("#div1").load("/try/ajax/demo_test.txt #p1");
  });
});
</script>
</head>
<body>
<div id="div1"><h2>使用 jQuery AJAX 修改文本</h2></div>
<button>獲取外部文本</button>
</body>
</html>

??? ?? ????? load() ??? ??? ??? ??? ?????. ??? ?? ??? ???????. ?? ??? ??? ????? ??? ? ????.

responseTxt - ?? ?? ? ?? ???? ?????.

statusTXT - ?? ??? ?????.

jQuery get() ? post() ???? ???? ???? ???? ? ?????. HTTP GET ?? POST ??? ??.

HTTP ??: GET ? POST????? ? ?? ? ??-??? ? ?? ???? ??? GET ? POST???. GET - ??? ????? ??? ?? POST - ??? ???? ??? ???? ??

GET? ????? ???? ???? ????(??) ? ?????. ??: GET ???? ??? ???? ??? ? ????.

POST? ???? ???? ???? ??? ?? ????. ??? POST ???? ???? ???? ??? ??? ?? ???? ??? ? ?? ?????.

jQuery $.get() ???

$.get() ???? HTTP GET ??? ?? ????? ???? ?????.

??: ??

$.get(URL,callback);

?? URL ????? ????? URL? ?????.

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

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("/try/ajax/demo_test.php",function(data,status){
alert("數(shù)據(jù): " + data + "\n狀態(tài): " + status);
});
});
});
</script>
</head>
<body>
<button>發(fā)送一個 HTTP GET 請求并獲取返回結(jié)果</button>
</body>
</html>

$.get()? ? ?? ????? ????? URL("demo_test.php")???.

? ?? ????? ?? ?????. ? ?? ?? ????? ??? ???? ??? ????, ? ?? ?? ????? ?? ??? ?????.

?: ? PHP ??("demo_test.php")? ??? ?????:

<?php
echo '??? PHP ???? ?? ??????. ';
?>

jQuery $.post() ???

$.post() ???? HTTP POST ??? ?? ??? ???? ?????.

??:

$.post(URL,data,callback);

?? URL ????? ????? URL? ?????.

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

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

?? ????? $.post()? ???? ??? ?? ???? ????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("/try/ajax/demo_test_post.php",{
name:"php中文網(wǎng)",
url:"http://ipnx.cn"
},
function(data,status){
alert("數(shù)據(jù): \n" + data + "\n狀態(tài): " + status);
});
});
});
</script>
</head>
<body>
<button>發(fā)送一個 HTTP POST 請求頁面并獲取返回內(nèi)容</button>
</body>
</html>

$.post()? ? ?? ????? ????? URL("demo_test_post.php")???.

?? ?? ??(?? ? ??)? ?? ???? ????.

"demo_test_post.php"? PHP ????? ??? ????? ?? ??? ? ??? ?????.

? ?? ????? ?? ?????. ? ?? ?? ????? ??? ???? ??? ????, ? ?? ????? ?? ??? ?????.

?: ? PHP ??("demo_test_post.php")? ??? ????:

<?php
$name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
$city = isset($_POST['url']) ? htmlspecialchars($_POST['url']) : '';
echo '網(wǎng)站名: ' . $name;
echo "\n";
echo 'URL 地址: ' .$city;
?>


???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $.post("/try/ajax/demo_test_post.php",{ name:"php中文網(wǎng)", url:"http://ipnx.cn" }, function(data,status){ alert("數(shù)據(jù): \n" + data + "\n狀態(tài): " + status); }); }); }); </script> </head> <body> <button>發(fā)送一個 HTTP POST 請求頁面并獲取返回內(nèi)容</button> </body> </html>