1. #21
    Sencha User
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
    Adriano72 is on a distinguished road

      0  

    Default


    Ciao Bclinton!

    sono contento di aver trovato un altro fan della Magica!!

  2. #22
    Sencha User
    Join Date
    Sep 2011
    Posts
    31
    Vote Rating
    0
    clabasky is on a distinguished road

      0  

    Default stillll can't get it!

    stillll can't get it!


    hey everyone,
    I stillll can't figure this scripttag nonsense out! I understand that I need to wrap the response in a callback function using the php code, but I don't understand how that happens. how/when does the php get called? where do I put the php code? Soooo confused pleeeassse help!!!!

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

      0  

    Default


    Quote Originally Posted by clabasky View Post
    how/when does the php get called? where do I put the php code?
    You put it on your server.

    Either you're not explaining yourself well or you're missing some core concepts that are common in all web applications.

  4. #24
    Sencha User
    Join Date
    Sep 2011
    Posts
    31
    Vote Rating
    0
    clabasky is on a distinguished road

      0  

    Default


    Quote Originally Posted by bclinton View Post

    Either you're not explaining yourself well or you're missing some core concepts that are common in all web applications.
    I think it's a lot of both!

    I'm used to doing ajax requests, where I send some params to a php file on my server, and it echos back a response. I'm not sure how to incorporate the php file with the scripttag proxy or jsonp request. What do I name it? and how does it get called?

    This code sends me a valid json file, but I get the "uncaught syntax error: unexpected token :"

    Maybe you can give me a hint?

    Code:
    searchlocations: function(){	
    
    
    PlacesStore = new Ext.data.Store({
        model: 'places',
        proxy: {
            type: 'scripttag',
            url: 'https://maps.googleapis.com/maps/api/place/search/json?location=42.3881379%2C-71.1320659&radius=5000&types=establishment%7Cstore%7Cfood%7Crestaurant%7Cgrocery_or_supermarket&name=burger&sensor=true&key=AIzaSyBcl1TJuKA9qVJNBF1tf4TggBNndMgtLes',
    	reader: {
                        type: 'json',
                        root: 'results'
                    }
        }
    });
    
    
    PlacesStore.load({
    scope: this,
    callback: function(records, operation, success){
    	
    }
    
    
    });
    
    
    }

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

      0  

    Default


    You can't use a scripttag proxy if you don't control the response on the server. In this case, you are making a request from google, not your own server, and you can't expect them to wrap the response in a callback function (as far as I know)

    Try using a json proxy.

  6. #26
    Sencha User
    Join Date
    Sep 2011
    Posts
    31
    Vote Rating
    0
    clabasky is on a distinguished road

      0  

    Default


    Ok! that makes more sense. I've tried the same thing with jsonp and it gives me the exact same error

    Code:
    searchlocations: function(){
    	
    	var latitude = locationstore.data.items[0].data.latitude;
    	var longitude = locationstore.data.items[0].data.longitude;
    	
    	var location = latitude+','+longitude;
    	var googleplaces = 'https://maps.googleapis.com/maps/api/place/search/json';
    	var name = searchlocationfieldset.items.items[0].getValue();
    	
    	console.log(location);
    	console.log(name);
    		
    	
    	Ext.util.JSONP.request({
    		url: 'https://maps.googleapis.com/maps/api/place/search/json?location=42.3881379%2C-71.1320659&radius=5000&types=establishment%7Cstore%7Cfood%7Crestaurant%7Cgrocery_or_supermarket&name=burger&sensor=true&key=AIzaSyBcl1TJuKA9qVJNBF1tf4TggBNndMgtLes'
    		callbackkey: 'callback',
    		callback: function(data) {
    			
    			 var places = data.results;
    			 PlacesStore.add(places);
    			console.log(places);
    			
    		}
    	});
    }

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

      0  

    Default


    Quote Originally Posted by bclinton View Post
    Try using a json proxy.
    I'm sorry, I meant an ajax proxy.

  8. #28
    Sencha User
    Join Date
    Sep 2011
    Posts
    31
    Vote Rating
    0
    clabasky is on a distinguished road

      0  

    Default


    an ajax proxy doesn't work because you can't do an ajax request across different domains. It has to be a jsonp request or scripttag proxy

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

      0  

    Default


    Oh yeah. I haven't used Touch in a while (this is an old thread) and I was thinking that restriction didn't apply, but I guess that is only with apps compiled with phonegap.

    You could always write a simple server component that relays the response from google, perhaps using cUrl: http://php.net/manual/en/book.curl.php

    But I think you should look into the google docs further. One would think they've got to have some way to wrap the response in a callback function, although this thread indicates they do not: http://www.sencha.com/forum/showthre...s-throws-error (But that's an old thread so I wouldn't take it on face value.)

    At this point though, to debug it you can take Sencha completely out of the equation. If you can't force the Google API to wrap their response in a callback function by manipulating the URL in the address bar of your web browser, you're probably not going to get Touch to do it.