Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the steps to read the page using jQuery+ajax using the get() function

php中世界最好的语言
Release: 2018-04-25 15:11:02
Original
2267 people have browsed it

This time I will bring you a detailed explanation of the steps to read the page using jQuery ajax's get() function. What are the precautions for using jQuery ajax's get() function to read the page? The following is a practical case, let’s take a look.

First introduce the get() function:

url,[data],[callback],[type]
Copy after login

Parameter description:

url: URL address of the page to be loaded
data: Key/value parameter to be sent.
callback:
Callback function when loading is successful. type: Return content format, xml, html, script, json, text, _default.

First create the testGet.php instance:

<?php
$web = $_GET[&#39;webname&#39;];
echo "你现在访问的网站是:".$web;
?>
Copy after login

Then create the ajax.html file:

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

I believe you have mastered the method after reading the case in this article, and more How exciting, please pay attention to other related articles on php Chinese website!

Recommended reading:

Detailed explanation of the steps of ajax reading properties

Summary of jquery ajax form submission method

The above is the detailed content of Detailed explanation of the steps to read the page using jQuery+ajax using the get() function. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!