1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    3
    Vote Rating
    0
    treelovinhippie is on a distinguished road

      0  

    Default Unanswered: How to accept JSONP with text/plain MIME type?

    Unanswered: How to accept JSONP with text/plain MIME type?


    Hi

    I'm trying to load basic JSON from an external source that I don't have control of, using the proxy:

    Code:
                    proxy: {                    type: 'jsonp',
                        url: 'http://thejsonurl....',
                        
                        reader: {
                            type:'json',
                            rootProperty:''
                        }
    
    
                    }
    However, I get this error:
    Code:
    Resource interpreted as Script but transferred with MIME type text/plain:
    Is there a way around this?

    Cheers

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,015
    Answers
    3491
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Your response needs to return the Content-Type header as application/javascript. For PHP you can do it like:

    PHP Code:
    header('Content-Type: application/javascript'); 
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    3
    Vote Rating
    0
    treelovinhippie is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Your response needs to return the Content-Type header as application/javascript. For PHP you can do it like:

    PHP Code:
    header('Content-Type: application/javascript'); 
    Problem is, I don't control or have access to the data source. I can't change the generated JSON output

  4. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    3
    Vote Rating
    0
    treelovinhippie is on a distinguished road

      0  

    Default


    Oh well, my workaround was to have a separate php file that basically grabbed the external json and echo'd it out with the proper headers, and then change the proxy type to ajax.

    This actually makes sense anyway for me if the external data source changes

    Code:
    header('Content-type: application/json');
    
    $html = file_get_contents('http://external_json_file');
    
    
    echo $html;

Thread Participants: 1

Tags for this Thread