jQuery+ajax使用get()函数读取页面步骤详解

php中世界最好的语言
php中世界最好的语言 原创
2018-04-25 15:11:02 1921浏览

这次给大家带来jQuery+ajax使用get()函数读取页面步骤详解,jQuery+ajax使用get()函数读取页面的注意事项有哪些,下面就是实战案例,一起来看一下。

首先介绍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>

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

ajax读取properties步骤详解

jquery+ajax提交form表单方法总结

以上就是jQuery+ajax使用get()函数读取页面步骤详解的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。