1. #1
    Touch Premium Member
    Join Date
    May 2011
    Location
    Norfolk & DC
    Posts
    100
    Vote Rating
    5
    epiphanydigital is on a distinguished road

      0  

    Default "Uncaught SyntaxError: Unexpected token :" when using JSONP and scripttag

    "Uncaught SyntaxError: Unexpected token :" when using JSONP and scripttag


    Does anyone have any idea why this wouldn't work? I get the error when trying to load the json from my server.

    "Uncaught SyntaxError: Unexpected token :" when using JSONP and scripttag

    It works fine when the very same is loaded from the yahoo server.

    Code:
    Ext.regModel('MenuItem', {
      fields: [
        {name: 'id',      type: 'int'},
        {name: 'title',    type: 'string'}
        //{name: 'body',     type: 'string'}
      ]
    });
    
    MyDS.MenuStore = new Ext.data.Store({
      model: 'MenuItem',
      proxy: {
        //type: 'ajax',
        type: 'scripttag',
        url: 'http://1ldev251.iqsolutions.com/myds2-rpc/testing.json', // DOES NOT WORK, EXACTLY THE SAME CONTENT AS THE BELOW URL:
        //url: 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22hello%22%20limit%2010', // WORKS!
        reader: new Ext.data.JsonReader({
          root: 'query.results.photo'
        })
      }
    });

  2. #2
    Sencha User
    Join Date
    Oct 2008
    Posts
    9
    Vote Rating
    0
    derickito is on a distinguished road

      0  

    Default Correct url?

    Correct url?


    When I go to the url: http://1ldev251.iqsolutions.com/myds2-rpc/testing.json i get a 404. Did you remove the file already?

  3. #3
    Touch Premium Member
    Join Date
    May 2011
    Location
    Norfolk & DC
    Posts
    100
    Vote Rating
    5
    epiphanydigital is on a distinguished road

      0  

    Default


    No, sorry, it's over a VPN. I am connected. I get the same issue if I put the file elsewhere. It is literally a copy/paste contents of the yahoo version though.

  4. #4
    Touch Premium Member
    Join Date
    May 2011
    Location
    Norfolk & DC
    Posts
    100
    Vote Rating
    5
    epiphanydigital is on a distinguished road

      0  

    Default


    The same can be found publically at http://www.epiphanydigital.com/testing.json

  5. #5
    Sencha User
    Join Date
    Oct 2008
    Posts
    9
    Vote Rating
    0
    derickito is on a distinguished road

      0  

    Default


    Well I still can't see it, but I suggest you check that you can access the url via your browser. (I'm sure you've done this, just trying to eliminate the obvious)

  6. #6
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    265
    Vote Rating
    5
    bclinton will become famous soon enough

      0  

    Default


    When using JSONP you need to wrap the response in a callback function. The name of the callback function will be automatically sent so you need to retrieve it server side and use it to wrap the response that you send back. Check out the examples in the docs for scripttagproxy: http://dev.sencha.com/deploy/touch/d...ScriptTagProxy

  7. #7
    Touch Premium Member
    Join Date
    May 2011
    Location
    Norfolk & DC
    Posts
    100
    Vote Rating
    5
    epiphanydigital is on a distinguished road

      0  

    Default


    Yeah, I have no problem accessing with the browser. Definitely the first thing worth checking. Thanks!

  8. #8
    Touch Premium Member
    Join Date
    May 2011
    Location
    Norfolk & DC
    Posts
    100
    Vote Rating
    5
    epiphanydigital is on a distinguished road

      0  

    Default


    Bclinton... so... let me follow that up with, is there a better way to approach this? I am using Drupal as the json provider using the views datasource module (not sure how familiar with Drupal you are). The data in this case is uni-directional, meaning the phone will not be pushing data to Drupal, only the other way around.

    I do need the data to be available to the phone offline... so I would like to be able to use a json data store like in my above code and then use a local storage proxy as a backup when internet is unavailable.

    Changed my store to: (now getting the error "Uncaught ReferenceError: mycallback is not defined", which is strange to do anyway since the response from yahoo isn't wrapped in a callback function)

    Code:
    MyDS.MenuStore = new Ext.data.Store({
      model: 'MenuItem',
      proxy: {
        type: 'scripttag',
        //url: 'http://1ldev251.iqsolutions.com/myds2-rpc/menu.json',
        url: 'http://1ldev251.iqsolutions.com/myds2-rpc/testing.json',
        callbackParam: 'mycallback',
        //url: 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22hello%22%20limit%2010',
        reader: new Ext.data.JsonReader({
          root: 'query.results.photo'
          //root: 'Items.node'
        })
      }
    });
    And the return from the server to:

    Code:
    mycallback({"query":{"count":10,"created":"2011-06-27T16:56:19Z","lang":"en-US","results":{"photo":[{"farm":"6","id":"5877755168","isfamily":"0","isfriend":"0","ispublic":"1","owner":"11534192@N00","secret":"ea772d9d87","server":"5153","title":"Hello Kitty grabber!"},{"farm":"6","id":"5877200219","isfamily":"0","isfriend":"0","ispublic":"1","owner":"51741677@N02","secret":"39d8bbcef3","server":"5188","title":"Well...HELLO BEAUTIFUL. *_*"},{"farm":"6","id":"5877726942","isfamily":"0","isfriend":"0","ispublic":"1","owner":"24475351@N06","secret":"bfc2c939c4","server":"5147","title":"? FA MELISSA GLAM MM ?"},{"farm":"6","id":"5877721792","isfamily":"0","isfriend":"0","ispublic":"1","owner":"61994437@N02","secret":"d542f31a8c","server":"5234","title":"Hello World~"},{"farm":"6","id":"5877729046","isfamily":"0","isfriend":"0","ispublic":"1","owner":"55141349@N00","secret":"efc354e2a0","server":"5308","title":"Hello World"},{"farm":"6","id":"5877666982","isfamily":"0","isfriend":"0","ispublic":"1","owner":"11569107@N06","secret":"1f938dd80c","server":"5310","title":"Hello, anyone home? :))"},{"farm":"6","id":"5877130213","isfamily":"0","isfriend":"0","ispublic":"1","owner":"62584866@N05","secret":"f09658b0fe","server":"5062","title":"hello, love."},{"farm":"6","id":"5877658692","isfamily":"0","isfriend":"0","ispublic":"1","owner":"66624974@N00","secret":"ff0d17ff03","server":"5318","title":"hello down there!"},{"farm":"6","id":"5877632774","isfamily":"0","isfriend":"0","ispublic":"1","owner":"9250234@N04","secret":"8701d5a1ff","server":"5262","title":"hello there"},{"farm":"6","id":"5877632930","isfamily":"0","isfriend":"0","ispublic":"1","owner":"40739214@N08","secret":"8a335fe305","server":"5303","title":"?? ?? ?? ~ ?? onii ?"}]}}});

  9. #9
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    265
    Vote Rating
    5
    bclinton will become famous soon enough

      0  

    Default


    I think you have the same misconception I had when I started with JSONP and ScriptTagProxy. You are defining your callback, and then wrapping your response with the callback function you defined.

    But it doesn't work that way. The callback function name is generated automatically. Even if you define it in the callbackParam config option as "mycallback", it's still going to come through as "mycallback0002" (or something like that). You must retrieve the callback function name on the server side from the request that is generated by your ScriptTagProxy.

    The best way to understand this is to look at the PHP, ASP, etc examples in the ScriptTagProxy docs. See how the PHP example shows the retrieval of the callback name from the $_REQUEST:

    Code:
    $callback = $_REQUEST['callback'];
    Well, that's the first line of code I cut out of my tests because I was using callbackParam so I didn't need it, right? No, wrong. You need it.

    I don't know if the Drupal Views Datasource module does this. You may have to modify the module.

    Another very important thing here that you may be missing is that you only need to use JSONP and ScriptTagProxy when you are sending the request to a different domain. All this callback stuff is part of the mechanism that allows you to get around the same domain restriction. If you are serving your Sencha Touch app from the same domain as your Drupal installation, you should just be able to use regular JSON (no wrapper) with an AjaxProxy and a JsonReader. (But if you eventually intend to package your app as a native app with Phonegap you will need to use JSONP/ScriptTag)

  10. #10
    Sencha User
    Join Date
    Aug 2010
    Posts
    82
    Vote Rating
    0
    jacstofberg is on a distinguished road

      0  

    Default


    epiphanydigital,

    For a while I had the same error pop up on the console. My problem turned out to be that the remote server blocked my request.

    What does your server side code look like? Do you by any chance read from a MySql database and are trying to return the results?

    If so, maybe you've got the same problem I had, and I can possibly help.

    Cheers,
    Jac

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar