使用 ajax 在 html 页面中的重定向函数



我今天访问了这个网站页面。在第 3 页顶部有单选链接按钮。当我单击惊讶时,没有Amy窗口加载功能,我将立即移动到第二页,因为希望我单击单选按钮。

我还查看了 ajax 代码的源代码,但没有可用的代码。

我还想在我的网站上创建相同的内容,当用户单击任何链接或按钮或输入时,页面永远不会通过链接页面功能加载所有内容。

请帮助我如何创建这样的代码. 请举个例子教我。

提前谢谢。

这项技术称为">通过AJAX加载页面内容"。您可以在谷歌上搜索此关键字以了解其工作原理。

这是jQueryjavascript库的工作演示。您可以在脚本标签中检查我的代码和注释。(在编辑器中单击"index.html"文件中的启动(

友情链接 : https://plnkr.co/IMHyUwI4zllOwlCXb6b5

法典:

/* When the DOM ready */
$(document).ready(function() {
/* Do */
/* Load content to div has id = main, from url = 'r1.html' (default state for fisrt visit time)*/
$('#main').load('r1.html');
/* Find input with id = r1, bind to click event */
$('#r1').on('click', function() {
/* when it get clicked , load content to div has id = main, from url = 'r1.html' */
$('#main').load('r1.html');
});
/* Find input with id = r2, bind to click event */
$('#r2').on('click', function() {
/* when it get clicked , load content to div has id = main, from url = 'r2.html' */
$('#main').load('r2.html');
});
/* Find input with id = r3, bind to click event */
$('#r3').on('click', function() {
/* when it get clicked , load content to div has id = main, from url = 'r2.html' */
$('#main').load('r3.html');
});
});

最新更新