First introduce the get() function:
url,[data],[callback],[type]
Parameter description:
url: URL address of the page to be loaded
data: Key/value parameters to be sent.
callback: callback function when loading is successful.
type: Return content format, xml, html, script, json, text, _default.
First create a testGet.php instance:
<?php $web = $_GET['webname']; echo "你现在访问的网站是:".$web; ?>
Then create the ajax.html file:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>php点点通 - 关注php开发,提供专业web开发教程! </title> <script type="text/javascript" src="./jquery-1.7.1.min.js"></script> <script> $(document).ready(function(){ $("#btn").click(function(){ $.get("testGet.php",{web:"www.phpddt.com"},function(data,textStatus){ $("#result").append("data:"+data); $("#result").append("<br>textStatus:"+textStatus); }); }); }); </script> </head> <body> <input type="button" value="测试" id="btn" /> <h2>显示的内容如下:</h2> <div id="result"></div> </body> </html>
The initial page before testing is:
The result after clicking the test is: