-
Notifications
You must be signed in to change notification settings - Fork 35
/
ajax.load.html
71 lines (68 loc) · 2.3 KB
/
ajax.load.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Пример загрузки HTML посредством метода "load()"</title>
<link rel="profile" href="https://gmpg.org/xfn/11"/>
<link rel="shortcut icon" href="https://anton.shevchuk.name/favicon.ico"/>
<link rel="stylesheet" href="css/styles.css"/>
<style>
main {
height: 480px;
overflow: auto
}
</style>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/code.js"></script>
</head>
<body>
<header>
<h1>Пример загрузки HTML</h1>
<h2>Используем метод <code>load()</code></h2>
</header>
<main>
<article>
<h3>Пробуем загрузить контент →</h3>
</article>
<article id="content">
</article>
</main>
<footer>
© <a href="https://anton.shevchuk.name/jquery-book/">jQuery for beginners</a>
</footer>
<aside>
<nav>
<a href="index.html#60" title="go back" rel="prev">Back</a>
<a href="index.html#60" title="back to Index" rel="index">Index</a>
<a href="#" title="reload" onclick="window.location.reload();return false">Reload</a>
<a href="ajax.html" title="go next" rel="next">Next</a>
</nav>
<hr/>
<div>
<code contenteditable="true"><em>// AJAX is easy</em>
<em>// load a page</em>
$(<span>"#content"</span>)
.load(<span>"example.html"</span>)</code>
<button type="button">Run Code</button>
<code contenteditable="true"><em>// load a part</em>
$(<span>"#content"</span>)
.load(<span>"example.html main"</span>)</code>
<button type="button">Run Code</button>
<code contenteditable="true"><em>// load another part</em>
$(<span>"#content"</span>)
.load(<span>"example.html article:first"</span>)</code>
<button type="button">Run Code</button>
<code contenteditable="true"><em>// easy to handle</em>
$(<span>"#content"</span>)
.load(<span>"example.html article:first p"</span>, function(){
<em>// the data has been loaded</em>
$(this)
.find(<span>"p"</span>)
.fadeOut(<i>2000</i>);
})</code>
<button type="button">Run Code</button>
</div>
</aside>
</body>
</html>