首页 > Web开发 > 详细

20151211jquery ajax进阶代码备份

时间:2015-12-11 22:04:45      阅读:290      评论:0      收藏:0      [点我收藏+]
//数据处理
	
	$(‘form input[type=button]‘).click(function() {
		//json处理
        /*$.ajax({
			type:‘POST‘,
			url:‘test.json‘,
			dataType:‘json‘,
			data:$(‘form‘).serialize(),
				success: function(response,status,xhr){
					alert(response[0].url);
					}
			});
			*/
			
			//本地获取jsonp.php成功
			/*$.ajax({
				type:‘POST‘,
				url:‘jsonp.php‘,
				dataType:‘json‘,
				success: function(response,status,xhr){
					alert(response.a);
					}
				
			});*/
			
			
			//跨域获取jsonp.php,失败
			/*$.ajax({
				type:‘POST‘,
				url:‘http://www.li.cc/jsonp.php‘,
				dataType:‘json‘,
				success: function(response,status,xhr){
					alert(response.a);
					}
				
			});*/
			//本地获取jsonp2.php成功
			/*$.getJSON(‘jsonp2.php?callback=?‘,function(response){
				alert(response.a);
				});*/
				
				//跨域,远程,成功
			/*$.getJSON(‘http://www.li.cc/jsonp2.php?callback=?‘,function(response){
				alert(response.a);
				});*/
				
				/*$.ajax({
				type:‘POST‘,
				url:‘jsonp2.php‘,
				dataType:‘jsonp‘,
				success: function(response,status,xhr){
					alert(response.a);
					}
				
			});*/
			
			
			
			//jqXHR对象
			//jqXHR就是$.ajax 返回的对象
			/*var jqXHR=$.ajax({
			type:‘POST‘,
			url:‘user.php‘,
			data:$(‘form‘).serialize()
			});*/
			//alert(jqXHR);
			/*jqXHR.success(function(response){
				alert(response);
				
				});*/
		/*jqXHR.done(function(response){
			alert(response+‘1‘);
			}).done(function(response){
				alert(response+‘2‘);
				});//可以连缀操作
				
		jqXHR.done(function(response){
			alert(response+‘3‘);
			});*/
			
			
			
			var jqXHR=$.ajax(‘t1.php‘);
			var jqXHR2=$.ajax(‘t2.php‘);
			
			/*jqXHR.done(function(response){
				alert(response);
				});
				
				jqXHR2.done(function(response){
				alert(response);
				});*/
				
		$.when(jqXHR,jqXHR2).done(function(r1,r2){
			alert(r1[0]);
			alert(r2[0]);
			});
    });

  

20151211jquery ajax进阶代码备份

原文:http://www.cnblogs.com/xiaoduc-org/p/5040190.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!