国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

?? PHP ?? ????: ??? ?? ???

1. ??? ?? ???

1. XMLHttpRequest ??? ??? ???? ???? ? ?????.

2. ??? ?? ???

  • ??? ??? ??? ?? open() ? send() ???:

xmlhttp.open("GET","test1.txt",true);

xmlhttp.send();

5.png

3. GET ?? POST ??

  • POST? ?? GET? ? ???? ???, ?? ???? ?????.

  • ?, ??? ?? ???? POST ??? ??? ??? ????.

  • ?? ??? ??? ? ????(?? ?? ????) ?? ??????)

  • ??? ??? ???? ??? ??(POST?? ??? ??? ????.)

  • ? ? ?? ??? ??? ??? ??? ??? ?? , POST? GET?? ????? ??? ? ????

???? ? ? ?? ??? ???? ? ??? ?? ?? ?? ???????

4.

  • ??? GET ??:

?? ?? 2_1.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","2_2.php",true);
xmlhttp.send();
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button>
<div id="myDiv"></div>
</body>
</html>

?? ?? 2_2.php

<?php
echo "使用GET方法請(qǐng)求得到的<br/>";
echo date("Y-m-d h:i:s",time());
?>

  • GET ???? ??? ????? URL? ??? ?????:

?? ?? 2_5.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","2_6.php?name=小明",true);
xmlhttp.send();
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button>
<div id="myDiv"></div>
</body>
</html>

???? 2_6.php

<?php
$name=$_GET['name'];
echo "使用GET方法請(qǐng)求得到的<br/>";
echo "你好".$name."同學(xué)";
?>

5. POST ??

  • ???? 2_3.php

  • <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <script>
    function loadXMLDoc()
    {
    var xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("POST","2_4.php?",true);
    xmlhttp.send();
    }
    </script>
    </head>
    <body>
    <h2>AJAX</h2>
    <button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button>
    <div id="myDiv"></div>
    </body>
    </html>
2_4.php

<?php
echo "使用POST方法請(qǐng)求得到的<br/>";
echo date("Y-m-d h:i:s",time());
?>

  • HTML ??? ?? ???? POST?? ?? ?? setRequestHeader()? ???? HTTP ??? ?????. ?? ?? send() ????? ???? ???? ??????:

?? ?? 2_7.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST","2_8.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("name=小明&age=22");
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button>
<div id="myDiv"></div>
</body>
</html>

2_8.php

<?php
$name=$_POST['name'];
$age=$_POST['age'];
echo "使用POST方法請(qǐng)求得到的<br/>";
echo "大家好,我叫".$name."今年".$age."歲";
?>

6.png

6. ?? ??

(1) url - ??? ?? ??

  • open () ???? url ????? ??? ?? ??? ?????:

xmlhttp.open("GET","ajax_test.php",true);

  • ??? .txt ? .xml? ?? ?? ??? ????? .asp ? .php? ?? ?? ???? ??? ? ????(??? ?? ???? ??? ??? ? ??). ??) .

(2) Asynchronous-true/false

AJAX? Asynchronous JavaScript? XML? ?????.

XMLHttpRequest ??? AJAX? ????? ?? open() ???? async ?? ??? true? ???? ???.

xmlhttp.open("GET","ajax_test.php ",true) ;

  • ??? ?? ??? ? ????? ? ?????. ???? ???? ?? ???? ??? ?? ????. AJAX ???? ?? ?? ??????? ????? ??? ? ?????.

  • AJAX? ???? JavaScript? ??? ??? ??? ??? ????. ??

  • ?? ??? ?????. ??? ??? ???? ?? ?? ????

  • ??? ???? ??? ?????.

(3) ??? =true

async=true? ???? ?? onreadystatechange ????? ?? ??? ??? ? ??? ??? ?????.

?? ??: 2_9.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","2_10.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">通過(guò)AJAX改變內(nèi)容</button>
<div id="myDiv"></div>
</body>
</html>

2_10.txt

這是通過(guò)AJAX得到的內(nèi)容?。?!

(4) Async=false

async=false? ???? ?? ?? ??? ?????. open() ???? ? ?? ????? false? ??:

xmlhttp.open("GET","test1.txt",false);

async=false? ???? ?? ???? ??? ?? ?? ??? ???? ?????.

JavaScript? ???? ?? ?? ??? ??? ??? ?????. ??? ???? ??? ??? ??????? ????? ?????.

??: async=false? ???? ?? onreadystatechange ??? ???? ?? send() ? ?? ??? ?????.

?? ??: 2_11 .php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","2_10.txt",false);
xmlhttp.send();
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button>
<div id="myDiv"></div>
</body>
</html>

2_10.txt

這是通過(guò)AJAX得到的內(nèi)容!!!


???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","2_2.php",true); xmlhttp.send(); } </script> </head> <body> <h2>AJAX</h2> <button type="button" onclick="loadXMLDoc()">請(qǐng)求數(shù)據(jù)</button> <div id="myDiv"></div> </body> </html>