2013-10-13 35 views
0

我試圖使用AJAX後到從Web服務拉列表...它不返回任何數據...這是我的電話的AJAX和AJAX函數:我知道它會返回數據,因爲我在後面的代碼中使用了這個函數。有什麼建議麼?AJAX郵政knockout.js數據綁定不工作

ko.applyBindings(new theatreSel.TheatreModel()); 
       Regal.showLocationModal(); 
       return false; 



    // declare viewmodel constructors in standard fashion 
    function TheatreModel() { 
     var self = this; 

     self.theatreData = ko.observableArray(); 

     $.ajax('/Services/TheatreLocationList.asmx/getTheatres', 
         { 
          data: {}, 
          type: 'POST', 
          contentType: 'application/json; charset=utf-8', 
          dataType: 'json' 

         }).success(function(data){ 
          self.theatreData = (data.d); 
          alert("success!"); 
         });        


    } 

和Web服務:

public class TheatreLocationList : System.Web.Services.WebService 
    { 
     // public IEnumerable<dynamic> TheatreList { get; set; } 

     [WebMethod]   
     public List<dynamic> getTheatres() 
     { 
      List<dynamic> TheatreList = new List<dynamic>(); 
      int radius = Regal.Core.Helpers.ConfigHelper.GetIntValue("SearchRadius", 30); 
      IFrdiTheatreRepository frdiTheatreRepo = FrdiTheatreRepository.CreateBusinessObject(); 
      TheatreCollection theatreCollection = frdiTheatreRepo.GetAllTheatresFromRegalByPostalCode("60613", radius); 
      TheatreList = (theatreCollection.ToList<dynamic>()); 
      return (TheatreList); 


     } 
    } 

回答

0

嘗試這樣的:

.success(function(data){ 
    self.theatreData(data.d); 
    alert("success!"); 
}); 
+0

謝謝你,我會努力! –

+0

非常感謝你,它的工作! –