2013-07-31 48 views

回答

0

這絕對是最好的網頁/網站看看。

http://api.jquery.com/jQuery.ajax/

,或者如果你想

http://www.w3schools.com/jquery/jquery_ref_ajax.asp

$.ajax({ 
    url : "page.asp", 
    data : { 
     "param1" : 1, 
     "param2" : "Hello World" //you can access these with the server's request object 
    }, 
    type : "GET", //or post 
    cache : true, //use your cache? (only applies to certain types) 
    dataType : "json", //what kind of data are you expecting? (or Intelligent guess) 
    success : function(message) { //message depends on dataType 
     console.log(message); 
    }, 
    error : function() { 
     console.log(arguments); 
    } 
}); 
0

有根據您的需要的方法很多,但常見的是

$.get('/yoururl',{inputParam:someVal},function(data){ 
    //do whatever with the returned data 

}); 
0

使用一個Web方法簡單的方法: jQuery AJAX call to an ASP.NET WebMethod
http://deebujacob.blogspot.ca/2012/01/aspnet-ajax-web-method-call-using.html

例如在你的aspx .cs:

 

    [WebMethod()] 
    public static string GetData(int userid) 
    { 
     /*You can do database operations here if required*/ 
     return "my userid is" + userid.ToString(); 
    } 

在你的aspx:

 

    function asyncServerCall(userid) { 
     jQuery.ajax({ 
    url: 'WebForm1.aspx/GetData', 
    type: "POST", 
    data: "{'userid':" + userid + "}", 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    success: function (data) { 
     alert(data.d); 
    } 

     }); 
    } 

相關問題