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

      0  

    Default Unanswered: Not able to get data from Google place API

    Unanswered: Not able to get data from Google place API


    Hi Guys!

    I am trying to receive data from google place api. I can not use JSONP proxy because response is not in form of it. I have to use normal ajax, but its giving me cross browser ajax related errors. I tried using

    Code:
      withCredentials: true,
                useDefaultXhrHeader: false,
    but still no luck.

    Can any one help me on this??

    My store looks like

    Code:
    Ext.define('BW.store.addplace.SearchPlaceStore',{
        extend:'Ext.data.Store',
        requires:['BW.model.addplace.SearchPlaceModel'],
        config:{
            model:'BW.model.addplace.SearchPlaceModel'
        },
        setQuery:function(query, apiKey){
            this.setProxy({
                type: "ajax",
                url : "https://maps.googleapis.com/maps/api/place/autocomplete/json?input="+ query +"&types=geocode&sensor=false&key=" + apiKey,
                reader: {
                    type: "json",
                    rootProperty: "predictions"
                },
                withCredentials: true,
                useDefaultXhrHeader: false,
            });
        }
    })

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,710
    Vote Rating
    436
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    What errors are you getting? Do they allow CORS?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

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

      0  

    Default


    XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place-----. Origin http://localhost is not allowed by Access-Control-Allow-Origin.


    I dont think they allow CORS. this service worked when I packaged my application in native wrapper. but when runnning on mobile browser, it throwing this error.

    So for now, I have used google api javascript functions to load data.