教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 jquery刷新页面代码及js常用函数汇总

jquery刷新页面代码及js常用函数汇总

发布时间:2015-10-21   编辑:jiaochengji.com
本文介绍下,jquery用于刷新页面的代码,包括局部刷新与全页面刷新,另外,为大家提供一份js常用函数列表。有需要的朋友参考下吧。

一、jquery局部刷新:
常见的有以下几种;
$.get方法,$.post方法,$.getJson方法,$.ajax方法。

前两种使用方法基本上一样。
 

复制代码 代码示例:
$.get(”Default.php”, {id:”1″, page: “2″ },
function(data){
//回调方法。返回data数据。这里想怎么处理就怎么处理了。
});

$.getScript方法:
 

复制代码 代码示例:
$.getScript(”/js/jquery.js”,
function(){
$(”#go”).click(function(){//回调方法
$(”.block”).animate( { backgroundColor: ‘pink’ }, 1000)
.animate( { backgroundColor: ‘blue’ }, 1000);
});
});

$.getJson只是返回的数据类型不一样:
 

复制代码 代码示例:
$.getJson(”Default.php”, {id:”1″, page: “2″ },
function(data){
//注意,这里返回的JSON数据引用方法为”data.info”
});

$.ajax 方法:
 

复制代码 代码示例:
$.ajax({
type: “POST”, //提交的类型
url: “some.php”,//提交地址
data: “name=John&location=Boston”,//参数
success: function(msg){ //回调方法
alert( “Data Saved: ” + msg );//这里是方法内容,和上面的get方法一样
}
});

二、全页面刷新方法
window.location.reload()刷新当前页面.
parent.location.reload()刷新父亲对象(用于框架)
opener.location.reload()刷新父窗口对象(用于单开窗口)
top.location.reload()刷新最顶端对象(用于多开窗口)

您可能感兴趣的文章:
jquery刷新页面代码及js常用函数汇总
javascript刷新当前页面方法汇总
js自动刷新页面代码汇总
jQuery 定时局部刷新(setInterval)方法总结
asp网页自动刷新方法汇总
jquery刷新页面 jquery局部刷新与及全页面刷新
jquery刷新页面的实现代码(局部及全页面刷新)
PHP与jquery实时显示网站在线人数的例子
js刷新页面方法汇总
js自动刷新当前页面方法详解

[关闭]
~ ~