Problem using RIA/JS

Topics: jQuery
Nov 16, 2011 at 1:02 PM

I have a problem using the RIA/JS library. I built an example like in the scenarios (simpleget), but when i call

$([persons]).dataSource({...}).refresh()

I get the following error:

SCRIPT5007: Unable to get value of the property 'length': object is null or undefined
jquery-1.6.1.js, line 613 character 4

My whole js-code to fetch the data is the following (the JSON Request works (returns the correct JSON response))

$(function () {
    var persons = [];
 
    // Bind arrayChange event to render ui.
    $([persons]).bind(
        "arrayChange",
        function () {
            $("#persons").empty().append($.render($.template("#person"), persons)); 
        }
    );
 
 
    // Bind array with data source and refresh.
    $([persons]).dataSource({
        serviceUrl: "RIAApplication-Web-Services-PersonDomainService.svc",
        queryName: "GetPersons"
    }).refresh();
});
Dec 6, 2011 at 12:06 AM

Is metadata being returned from the server?

Check that you have the "transmitMetadata" attribute set in the web.config ...

<domainServices>
    <endpoints>
        <add name="soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="JSON" transmitMetadata="true" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </endpoints>
</domainServices> 

Dec 6, 2011 at 7:11 AM

Hi!  metadata were already set to true. Any other ideas?

Dec 6, 2011 at 12:16 PM

Problem solved! Solution found in this thread: http://forums.silverlight.net/t/236962.aspx/1?Problem+going+to+through+BigShelf+RiaServices+Jquery+Metadata+is+undefined+

I've used a wrong version of Microsoft.ServiceModel.DomainServices.Hosting.dll!