|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>My Learning Website</title>
|
|
|
|
<link href="/styles/styles.css" rel="stylesheet" type="text/css">
|
|
|
|
<link href="/webdevelopment/styles/styles.css" rel="stylesheet" type="text/css">
|
|
|
|
<link href="../styles/samples.css" rel="stylesheet" type="text/css">
|
|
|
|
<script type="module" src="/scripts/article.js" defer></script>
|
|
|
|
<script type="text/javascript" src="/jQuery/jquery-3.6.3.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$("document").ready(function() {
|
|
|
|
$("#getcontent").click(getContent);
|
|
|
|
$("#loadhtml").click(loadHTML);
|
|
|
|
});
|
|
|
|
|
|
|
|
function getContent() {
|
|
|
|
$.ajax("sampletextcontent.txt",
|
|
|
|
{ success: setContent,
|
|
|
|
type: "GET",
|
|
|
|
dataType: "text" });
|
|
|
|
}
|
|
|
|
|
|
|
|
function setContent(data, status, jqxhr) {
|
|
|
|
$("#example").text(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadHTML() {
|
|
|
|
$("#example").load("osztromok");
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h1>AJAX and jQuery</h1>
|
|
|
|
<div id="content">
|
|
|
|
<p>One of jQuery's great strengths is how it simplifies working with AJAX. jQuery provides high-level wrapper functions
|
|
|
|
for retrieving data, working with different data types, handling errors, and monitoring the AJAX request process.</p>
|
|
|
|
<ul>
|
|
|
|
<li><code>ajax()</code>: used to perform generic AJAX requests</li>
|
|
|
|
<li><code>load()</code>: loads AJAX content directly into a page element</li>
|
|
|
|
</ul>
|
|
|
|
<div id="example">
|
|
|
|
</div>
|
|
|
|
<button id="getcontent">Get Text</button>
|
|
|
|
<button id="loadhtml">Load HTML</button>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|