jQuery UI Widgets Forums Grid Grid with JSONP not working

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 7 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Grid with JSONP not working #78093

    ysut
    Participant

    I tried to retrieve data thru web service from different domain. The code is below. Any ideas how come I always failed to display the results even I believe the web service was return correctly in JSON format?

    The API can accessed at http://ysoft.somee.com/ws/ysoftws.asmx/GetHistoryKursJSon?skdkurs=USD&callback=

    Thanks

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title id='Description'>In this example the Grid is bound to a Remote Data.</title>
        <link rel="stylesheet" type="text/css" href="jqwidgets/styles/jqx.base.css"/>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxdata.js"></script> 
        <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="jqwidgets/jqxgrid.selection.js"></script> 
        <script type="text/javascript" src="jqwidgets/jqxgrid.columnsresize.js"></script> 
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var source =
                {
                    type: "POST",
                    datatype: "jsonp",
                    datafields: [
                        { name: 'tgl_update' },
                        { name: 'hrg_jual' },
                        { name: 'hrg_beli' }
                    ],
                    url: 'http://ysoft.somee.com/ws/ysoftws.asmx/GetHistoryKursJSon',
                    data: {
                        skdkurs: 'USD',
                        callback: ''
                    },
                    root: "rec"
                };
                var dataAdapter = new $.jqx.dataAdapter(source);
    
                $("#jqxgrid").jqxGrid(
                {
                    width: 850,
                    source: dataAdapter,
                    columns: [
                        { text: 'Last Updated', datafield: 'tgl_update', width: 200 },
                        { text: 'Selling Price', datafield: 'hrg_jual', width: 170 },
                        { text: 'Buying Price', datafield: 'hrg_beli', width: 170 }
                    ]
                });
            });
    
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid"></div>
        </div>
    </body>
    </html>
    Grid with JSONP not working #78171

    Dimitar
    Participant

    Hello ysut,

    I think the following Stack Overflow topic will be helpful to you: http://stackoverflow.com/questions/5359224/parsererror-after-jquery-ajax-request-with-jsonp-content-type. Please refer to it.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.