AJAX = Asynchronous JavaScript And XML.
AJAX is not a programming language, it just uses a combination of:
AJAX is a developer's dream, because you can:
by W3C School
Tutorial in Mandarin: Build up web server
Step by step:
Usage Scenario: To create a personal blog or whatever main page containing URLs that needs to be transferred to other website.
As mentioned, before this menu page practice, we should create multiple HTML pages so that we can connect through the server. (I created Writing.html and Portfolio.html)
From the example above, AJAX helps request other pages’ data through the server immediately when we click Writing or Portfolio at this Menu page.
<body onload="getData('Writing.html')" style="font-family:Arial">
<div>
<span onclick="getData('Writing.html');">Writing</span>
<span onclick="getData('Portfolio.html');">Portfolio</span>
</div>
<!-- adding a horizontal line -->
<hr/>
<div id="content"></div>
<script type="text/javascript">
function getData(pageName){
//AJAX XMLHttpRequest object: for connecting with the server.
let req=new XMLHttpRequest();
req.open("get","http://127.0.0.1:8887/"+pageName); //setting the connection and URL.
req.onload=function(){ //Use load event to detect when the connection is finished.
// From here, the connection is done.
let content=document.getElementById("content");
content.innerHTML=this.responseText;
};
req.send();//Call the "send" to send out the connection request.
}
</script>
</body>
*Note:Add onload="getData('Writing.html')" to <body>
will present the Writing page's content once we open up the menu page.
Feel free to comment and share your ideas below to learn together!
If you guys find this article helpful, please kindly do the writer a favor — LIKE this article.
<<: D28-(9/28)-大台北(9908)-稳定的民生必需品,瓦斯
>>: TailwindCSS 从零开始 - 自订 addBase 套件
网站大致完成了,今天就来介绍 Chart.js 这个免费的资料视觉化套件 Chart.js Char...
_app.tsx 可以做什麽? App 跟 Document 皆是 Next.js 的进入点,而 D...
大家好!本篇将会以我转职的心路历程作为主轴,我为什麽转职成QA?当开发与当QA差很多吗?当QA该注意...
第十天 各位点进来的朋友,你们好阿 小的不才只能做这个系列的文章,但还是希望分享给点进来的朋友,知道...
1.除错 MySQL02影片00:01 2.MAD利用命令列进入MySQL $ % = 终端机 (1...