JQuery发送Ajax请求

$.ajax({
         url:'city/userInfo.action',    
         type: 'POST', 
         dataType: 'text',
         data: {name:"lixueli"},                
         timeout: 1000,                           
         error: function(){                      
         alert('Error loading XML document'); 
         }, 
         success: function(data){
         alert(data);
         }            
    });

JQuery发送post请求

$.post(
        url:"test.php", 
        data:{ "func": "getNameAndTime" },
        success:function(data){
           alert(data.name); // John
           console.log(data.time); //  2pm
        }, 
        type:"json"
        );                

JQuery发送get请求

$.get(
    utl:"test.cgi",
    date:{ name: "John", time: "2pm" },
    error:function(data){
        alert("Data Loaded: " + data);
    },
    success:function(data){
      alet(date);    
    }  
    
);
posted on 2012-10-19 23:03  java_fengyi  阅读(217)  评论(0编辑  收藏  举报