时间:2021-07-01 10:21:17 帮助过:6人阅读
首先介绍get()函数:
url,[data],[callback],[type]
参数说明:
url:待载入页面的URL地址
data:待发送 Key/value 参数。
callback:载入成功时回调函数。
type:返回内容格式,xml, html, script, json, text, _default。
首先建立testGet.php实例:
<?php $web = $_GET['webname']; echo "你现在访问的网站是:".$web; ?>
然见建立ajax.html文件:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> PHP </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>
<p id="result"></p>
</body>
</html>相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
推荐阅读:
jquery+ajax提交form表单方法总结
以上就是jQuery+ajax使用get()函数读取页面步骤详解的详细内容,更多请关注Gxl网其它相关文章!