[英]Redirect function in html page with ajax
这项技术称为“ 通过AJAX加载页面内容 ”。 您可以在Google上搜索此关键字以了解其工作原理。
这是jQuery javascript库的工作演示。 您可以检查我的代码并在脚本标记中进行注释。 (单击“ 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');
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.