0

我正在尝试使用 AJAX Post 从 Web 服务中提取列表......它没有返回任何数据......这是我对 AJAX 和 AJAX 函数的调用:我知道它返回数据,因为我使用过这个在我的代码后面的回发中。有什么建议么?

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!");
                       });                            


    }

和网络服务:

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


        } 
    }
4

1 回答 1

0

试试这样:

.success(function(data){
    self.theatreData(data.d);
    alert("success!");
}); 
于 2013-10-13T06:55:30.427 回答