首先介紹get()函數(shù):
url,[data],[callback],[type]
參數(shù)說明:
url:待載入頁面的URL地址
data:待發(fā)送 Key/value 參數(shù)。
callback:載入成功時回調(diào)函數(shù)。
type:返回內(nèi)容格式,xml, html, script, json, text, _default。
首先建立testGet.php實例:
<?php$web = $_GET['webname'];echo "你現(xiàn)在訪問的網(wǎng)站是:".$web;?>
然見建立ajax.html文件:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>php點點通 - 關注php開發(fā),提供專業(yè)web開發(fā)教程! </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>顯示的內(nèi)容如下:</h2><div id="result"></div></body></html> 測試前的初始頁面是:
點擊測試后的結果是:





















