Saturday, 15 June 2013

Sencha Touch 2.1 native (android) app not getting json from remote (it works on PC) -



Sencha Touch 2.1 native (android) app not getting json from remote (it works on PC) -

i created first sencha touch 2 app watching video (http://youtu.be/5f7gx0-w-m4) , has store page structured this:

ext.define('firstapp.store.places',{ extend:'ext.data.store', config:{ autoload:true, model:'firstapp.model.place', proxy:{ type:'ajax', url:'https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=aizasycfwzskdslql5gzr0ojlvcgoqjp1ukgz5u', reader:{ type:'json', rootproperty:'results' } } } })

the after-build (after running "sencha app build native") bundle work on mac (all browsers) generated app (i running on nexus phone) works doesn't collect info google maps json. help appreciated

the illustration referring using google map's place search api. can not utilize api when build app mobile phone proxy set ajax . basically, can not utilize resource outside domain. if site @ yourdomain.com , there someotherdomain.com, can't create ajax request someotherdomain.com yourdomain.com unless domain allows to. in case, mobile app not having domain. loading page within webview.

the reason is, ajax not able load cross-origin resources. app build works on browsers because believe you're using chrome --disable-web-security flag. work cors need utilize jsonp proxy. it's way if you're packaging mobile app. if in case, own server ( not in context though ) can allow cors setting appropriate headers

access-control-allow-origin: *

or

access-control-allow-origin: http://yourdomain.com/resource

try setting proxy jsonp .

android json proxy sencha-touch touch

No comments:

Post a Comment