Results 1 to 4 of 4

Thread: Can't parse a return string from JsonP!

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    13
    Vote Rating
    0
      0  

    Default Answered: Can't parse a return string from JsonP!

    Hi guy,
    I have made a request of JsonP, but the return string can't parse. I don't know why?
    I'm using Sencha touch 2.0.1.1, webservice: attach file, browser: Safari: 5.1.7, OS: window 7.
    This is my code (copy from JsonP example, but the url is my web service):
    Code:
    Ext.Viewport.add({
        xtype: 'button',
        text: 'Make JsonP Request',
        centered: true,
        handler: function(button) {
            // Mask the viewport
            Ext.Viewport.mask();
    
    
            // Remove the button
            button.destroy();
    
    
            // Make the JsonP request
            Ext.data.JsonP.request({
                url: 'http://localhost:7794/GetEmployees.svc/json/hello',
                callbackKey: 'callback',
                success: function(result, request) {
                    // Unmask the viewport
                    Ext.Viewport.unmask();
                }
            });
        }
    });
    This is a error:
    json-fail.jpg

    json-fail-detail.jpg

    What's a trouble? The string is a json string. But why it can't read it?
    Please help me to solve it, thanks!
    Attached Files Attached Files

  2. That's because your response is only JSON not JSONP. Sample JSONP is

    Code:
    Ext.data.JsonP.callback01({"success": true});

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    That's because your response is only JSON not JSONP. Sample JSONP is

    Code:
    Ext.data.JsonP.callback01({"success": true});
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    May 2012
    Posts
    13
    Vote Rating
    0
      0  

    Default jsonP string sample

    Hi mitchellsimoens,
    May you share me a sample jsonP string? It's so good if there is a sample of web service that return a jsonP string.
    I have tried to return a string like:
    Code:
    {"helloResult":"Ext.data.JsonP.callback1({sucess:true})"}

    But it's still not work.
    Thanks so much

  5. #4
    Sencha User
    Join Date
    May 2012
    Posts
    13
    Vote Rating
    0
      0  

    Default solved

    Hi, I have solved my trouble, we must config to WCF return the string in jsonP format.
    Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •