Home >Web Front-end >JS Tutorial >How to read the page through the ajax get() function in jQuery_jquery

How to read the page through the ajax get() function in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 15:12:571270browse

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:

<&#63;php
$web = $_GET['webname'];
echo "你现在访问的网站是:".$web;
&#63;>

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:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn