We help IT Professionals succeed at work.

Javascript error is hiding from me...

mmpd asked
Last Modified: 2012-05-31
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);


    $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!"

	[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/'

        // 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.

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

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

Open in new window

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.
Watch Question

Kyle HamiltonData Scientist
Most Valuable Expert 2014

Sorry. My previous comment was wrong. I took it out.
Data Scientist
Most Valuable Expert 2014
This one is on us!
(Get your first solution completely free - no credit card required)


Thank you once again very much.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.