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
Release: 2016-05-16 15:12:57
Original
1286 people have browsed it

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;>
Copy after login

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>
Copy after login

The initial page before testing is:

The result after clicking the test is:

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template