DataSource JSONP random callback function name

7 posts, 0 answers
  1. Jeff
    Jeff avatar
    18 posts
    Member since:
    Jun 2012

    Posted 10 Jun 2012 Link to this post

    I write only super high performance RESTful services that support both If-Modified-Since and If-None-Match request headers for data services.  Your randomization of the JSONP callback function name is killing my performance because it's making each subsequent request to the service random rather than static.  I don't see a way via configuration to make the JSONP call static and/or programmable.  Any suggestions?
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Jun 2012 Link to this post

    Hello,

     The Kendo UI DataSource relies entirely on $.ajax for making remote service requests. The jsonpCallbackString setting can be used to set your own callback name. Here is how to do this via the transport:

    var dataSource = new kendo.data.DataSource({
       transport: {
           read: {
               url: "....",
               jsonpCallbackString: "mycallback"
           }
        }
    });

    All the best,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Jeff
    Jeff avatar
    18 posts
    Member since:
    Jun 2012

    Posted 12 Jun 2012 Link to this post

    I downloaded version kendoui.complete.2012.1.515.commercial and am not seeing it working.  Here's my code:

                $("#productsTable").kendoGrid({
                    dataSource: {
                        type: "odata",
                        transport: {
                            read: {
                                url: "[ServiceUrl]"
                              , jsonpCallbackString: "mycallback"
                            }
                        },
                        pageSize: 5,
                        serverPaging: true,
                        serverFiltering: true,
                        serverSorting: true
                    },
                    rowTemplate: kendo.template($("#rowTemplate").html()),
                    filterable: true,
                    sortable: true,
                    pageable: true
                });
    

    Service call:
    /[Service]/[Endpoint]?$callback=jQuery171022314564533574405_1339541647044&%24inlinecount=allpages&%24format=json&%24top=5

    In which version is this fixed?  If not in the current build, can I get a hotfix?

    This configuration doesn't appear to be documented - http://www.kendoui.com/documentation/framework/datasource/configuration.aspx#transport.  Could you be sure to update the documentation?  All developers rely on it almost exclusively.

    http://www.kendoui.com/documentation/framework/datasource/configuration.aspx#read

    Thanks,
    Jeff
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Jun 2012 Link to this post

    Hi Jeff,

    I have mislead you in my previous reply. The right setting is jsonpCallback. Please accept my apologies.

    Here is a live demo showing how to use this setting: http://jsfiddle.net/korchev/QKtkx/1/ 

    Greetings,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Jeff
    Jeff avatar
    18 posts
    Member since:
    Jun 2012

    Posted 13 Jun 2012 Link to this post

    Thank you Atanas!  Using the jsonpCallback worked and my service automatically started working with 304 Not Modified, EXCELLENT!  I love <1ms service response time over the internet!

    Thanks for the update!
  7. Darren
    Darren avatar
    7 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    When I try this method, I still see a random value being generated:

    data: new kendo.data.HierarchicalDataSource({
        type: 'json',
        transport: {
            read: {
                url: '/common/menu',
                dataType: 'jsonp',
                contentType: 'application/json',
                jsonpCallback: 'myCallback'
            }
        },
        schema: {
            model: {
                children: 'Children'
            }
        }
    })

    This produces the following url:

    [base] ... /common/menu?callback=myCallback&_=1343050635987

    Is there anyway to not have that random string, so that this call can be cached?
  8. Stevoh
    Stevoh avatar
    1 posts
    Member since:
    May 2012

    Posted 28 Feb 2013 Link to this post

    Hi,
    I tried all the above techniques but they did not work, I then saw a post in stack overflow which advised to check the querystring variable 'callback' and set our jsonp function at the server side equivalent to that value, that way they would always be the same.
    check this out (describes asp.net web services but is easy to understand and replicate for other languages too) http://stackoverflow.com/questions/2380551/jquery-success-function-not-firing-using-jsonp
Back to Top
Kendo UI is VS 2017 Ready