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]);
    			});
        });
    

      

  • 相关阅读:
    PHP中的$_POST变量
    leetcode problem 32 -- Longest Valid Parentheses
    leetcode problem 31 -- Next Permutation
    leetcode problem 11 Container With Most Water
    leetcode problem 10 Regular Expression Matching(动态规划)
    leetcode problem 6 ZigZag Conversion
    leetcode problem (5) Longest Palindromic Substring
    leetcode problem (2-4)
    extern “C”的作用
    C++11中新特性之:unordered_map
  • 原文地址:https://www.cnblogs.com/xiaoduc-org/p/5040190.html
Copyright © 2011-2022 走看看