troubleshooting Question

Javascript error is hiding from me...

Avatar of mmpd
mmpd asked on
JavaScriptResponsive Web
3 Comments1 Solution594 ViewsLast Modified:
First thank you for helping me.

I am building a mobile app using JQuery Mobile and JayData.  The following code snippets demonstrate the problem I am having.  

(function (global, $data, undefined) {

    function registerEdmTypes() {

        function Edm_Int32() { };
        $data.Container.registerType('Edm.Int32', Edm_Int32);
        $data.Container.mapType(Edm_Int32, $data.Integer);

        function Edm_String() { };
        $data.Container.registerType('Edm.String', Edm_String);
        $data.Container.mapType(Edm_String, $data.String);
    };

    registerEdmTypes();

    $data.Entity.extend('smms.Entity.Note', {
        'Id':            { key: true, type: 'Edm.Int32', nullable: false, computed: true },
        'Task':         { type: 'Edm.String', nullable: false, required: true, maxLength: 255 },
        'Category':  { type: 'Edm.String', nullable: false, required: true, maxLength: 255 }
    });

    // Define smms.Entities to include the Notes entity 
    $data.EntityContext.extend('smms.Entities', {
        Notes:          { type: $data.EntitySet, elementType: smms.Entity.Note }
    });

})(window, $data);
// End of javascript file.

  
<!-- The following code is within index.html.  
      Include the necessary javascript files.
-->
<script type="text/javascript" src="./js/Libs/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="./js/Libs/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/Libs/cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/Libs/JayData-rc1-r1.min.js"></script>
<script type="text/javascript" src="./js/myapp/main.js"></script>


<script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);

    // once the device ready event fires, you can safely do your thing! -jm
    function onDeviceReady() {
        document.getElementById("welcomeMsg").innerHTML += "Cordova is ready!"
        $('#test').append("<li><h1>Test</h1></li>");

	[b]// It will silently bomb here!  Why and how do I fix it???
        var smmsContext = new smms.Entities({
            name: 'oData',
            oDataServiceHost: 'http://localhost:2343/ApplicationData.svc/'
        });[/b]

        // There is something wrong with the above new statement.
        // If the new statement is commented out then "Notes2" displays.
        // With the new left in "Notes2" doesn't display.  This means
        // that the new statement is bombing out and jumping to the end
        // of the script block.
        $('#notes').append("<li><h1>Notes2</h1></li>");

	// Helper function to format an li item.
        function createItemLI(name, id, css) {
            var li = $('<li></li>').append(name).addClass(css).data('id', id);
            return li;
        }

	// Display the notes as an unordered list.
        $(function () {
            smmsContext.Notes.toArray(function (notes) {
                notes.forEach(function (note) {
                    $('#notes').append(createItemLI(note.Id, note.Task, 'note'));
                });
            });
        });
    }
</script>

<body>
	<div id="welcomeMsg"></div>
	<ul id="test"></ul>
	<ul id="notes"></ul>
</body>

The backend database service is running.  If I type into the browser, 'http://localhost:2343/ApplicationData.svc/' I see a properly formatted xml layout of the service.  If I type into the browser, 'http://localhost:2343/ApplicationData.svc/Notes' I also see two records that are in the table Notes table.

The code bombs within this new statement.  Please help.
var smmsContext = new smms.Entities({
            name: 'oData',
            oDataServiceHost: 'http://localhost:2343/ApplicationData.svc/'
});

Again thank you for your help.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros