javascript - Extjs 5.0.1 How to send a JSON POST request the proper way -
good day all. i'm totally new extjs , i've been inserted big project started , left alone. i'm studing framework of course, i'm getting struck every bit of code.
now, i'd understand proper way make rest call, using json parameters in post.
this actual situation:
i have defined combobox in view file (called setup.js) , i've put listener on select following
emptytext: 'select country', listconfig: { itemtpl: [ '<div><span class="" style="margin-right: 10px;"><img src="resources/flags/{id}.png"></span>{name}</div>' ] }, listeners: { /*created after render listener wait until store loaded. set default value*/ select: 'oncountryselect', afterrender: 'onafterrendercombo' }
on file, called setupcontroller.js i've defined functions:
oncountryselect: function(a){ console.log("selected ",a.value); var controller = this, userdata = controller.getuserdata(); console.log("user.id",userdata.id); },
now, on every country select action, i've send json server, "set" country used user. call depends on enviroment dev 1 different production one, guess have make sort of proxy, maybe later issue, i'd setup call selection, i'll use logic future calls have do.
questions are, there proper way define it? need model? or have al calls in store? need a... proxy(?) or store or "external" can use same call in other places? there example this?
guys/girls, in advance.
like written here http://docs.sencha.com/extjs/6.0.2/classic/ext.data.proxy.ajax.html
a proxy made work server on same domain:
ajaxproxy cannot used retrieve data other domains. if application running on http://domaina.com cannot load data http://domainb.com because browsers have built-in security policy prohibits domains talking each other via ajax.
personally having console connecting more 1 server, use ajax request http://docs.sencha.com/extjs/6.0.2/modern/ext.ajax.html#method-request
ext.ajax.request({ url:'', method:'post', params:{ json:yourjson }, success:function(response){ }, failure:function(response){ } });
i'm working on personal proxy, extended ajax proxy, ajax call without different domain problems. if want home made proxy can read want proxy here: http://docs.sencha.com/extjs/6.0.2/classic/ext.data.proxy.proxy.html
or can use external js class ajax request you.
Comments
Post a Comment