zoukankan      html  css  js  c++  java
  • 20151211jquery ajax进阶代码备份

    //数据处理
    	
    	$('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]);
    			});
        });
    

      

  • 相关阅读:
    队列 和 线程 之GCD dispatch
    ios NSUserDefaults存储数据(偏好设置)
    Binary Tree postorder Traversal
    Binary Tree Inorder Traversal
    Binary Tree Preorder Traversal
    Rotate List
    Reversed Linked List(Reverse a singly linked list)
    Remove Element
    Swap Nodes in Pairs
    Add Two Numbers
  • 原文地址:https://www.cnblogs.com/xiaoduc-org/p/5040190.html
Copyright © 2011-2022 走看看