2014-03-29 112 views

回答

-1
Hi this is how can you retrive data using jquery 


$(document).ready(function() { 

$.ajax({ 
       type: "POST", 
       contentType: "application/json; charset=utf-8", 
       url: "URL/MethodName", 
       data: "{}",// you can provide parameteres to your function here 
       dataType: "JSOn", 
       success: function (data) { 
        for (var i in data) { 
       alert(data[i].Id); //assign to controls 
        alert(data[i].Header);// assign to controls 
        alert(data[i].Content) ;// assign to contols 
      } 

        alert('Data fetched Successfully'); 



       }, 
       error: function (result) { 
        alert('Data not fetched '); 

        return false; 
       } 

      }); 
    return false; 
}); 


/************************************************************************* 
[System.Web.Services.WebMethod] 
public ActionResult Careers() 
    { 
     List<JobOpening> job = new List<JobOpening>() 
     { 

     new JobOpening{Id = 1, Header = "Job1", Content = "edde" }, 
     new JobOpening{Id = 2,Header = "Job2", Content = "deded" }, 

     }; 



    } 
+0

不工作。:(希望你明白我的問題? – Richa