jQWidgets Forums

jQuery UI Widgets Forums General Discussions Lists ListBox JSON Parse Error while loading data from SQL Reply To: JSON Parse Error while loading data from SQL


Hristo
Participant

Hello bindu,

Semantic code looks correct. Only thing I noticed is that there are additional ‘});‘.

<script>
    var source = {
        dataType: "json",
        datafields: [
            { name: 'name' },
            { name: 'emailID' }
        ],
        url: 'select-data.jsp',
        async: true
    };

    var dataAdapter = new $.jqx.dataAdapter(source, {
        loadComplete: function () {
            var length = dataAdapter.records.length;
            alert(length);
        },
        loadError: function (msg, status, error) {
            alert(msg.responseText + " Error status:" + status + " Error is:" + error);
        }
    });

    $("#jqxListBox").jqxListBox({
        source: dataAdapter,
        displayMember: "name",
        valueMember: "emailID",
        width: 200,
        height: 250,
        selectedIndex: 0
    });
</script>

(corrected)

And one simulation of Your code: http://jsfiddle.net/txhi/p0kucrd6/

Best Regards,
Hristo Hristov

jQWidgets team
http://www.jqwidgets.com