1

I tried to accomplish the tutorial here, and when I used their data service, it worked just fine. I modified the source to my data service (WCF Data Service v5.6, OData V2), and the list just shows the Loading sign and nothing happens. The code should load any data type, it just has to be mapped accordingly. My service is availabe through the browser, I checked.

Here is the code:

DevExTestApp.home = function (params) {
  var viewModel = {
    dataSource: DevExpress.data.createDataSource({
      load: function (loadOptions) {
        if (loadOptions.refresh) {
          try {
            var deferred = new $.Deferred();
            $.get("http://192.168.1.101/dataservice/dataservice.svc/People")          
            .done(function (result) {
              var mapped = $.map(result, function (data) {
                return {                  
                  name: data.Name
                }
              });
              deferred.resolve(mapped);
            });
          }
          catch (err) {
            alert(err.message);
          }
          return deferred;
        }
      }
    })
  };
  return viewModel;
}

What else should I set?

shamp00
  • 11,106
  • 4
  • 38
  • 81
Nestor
  • 8,194
  • 7
  • 77
  • 156

1 Answers1

0

The try-catch block would not help is this case, because data loading is async. Instead, subscribe to the fail callback:

$.get(url)
    .done(doneFunc)
    .fail(failFunc);

Another common problem with accessing a web service from JavaScript is Same-Origin Policy. Your OData service have to support either CORS or JSONP. Refer to this discussion.

Community
  • 1
  • 1
amartynov
  • 4,125
  • 2
  • 31
  • 35