Mar162012
jquery ajax例子
作者:黑♂白 发布:2012-03-16 16:03:03 分类: web前端
经常用到jquery ajax,但有时候会忘记怎么写,下面做个笔记。 jquery ajax例子:
//post 方式
$.ajax({
url : 'test.php',
type : 'post',
data : {'act':'addvideo', 'videoname':videoname},//这里使用json对象
success : function(data){
//code here...
},
fail:function(){
//code here...
}
});
//get 方式
$.get("test.php", { name: "John", time: "2pm" }, function(data){ //code here... });
//get 方式2
$.ajax({
url : 'test.php',
data : {'act':'addvideo', 'videoname':videoname},//这里使用json对象
success : function(data){
//code here...
}
});
//jquery ajax同步方式
$.ajax({
url : 'test.php',
type : 'post',
async: false,//使用同步的方式
data : {'act':'addvideo', 'videoname':videoname},//这里使用json对象
success : function(data){
//code here...
},
fail:function(){
//code here...
}
});
本文固定链接: http://www.webzhishi.com/jquery-ajax-simple/ | web知识网
您还未登录,需要登录后才能发言