-
15 Jun 2012 7:35 PM #1
Unanswered: Passing Values from Date Picker/Select Field to URL Query - How?
Unanswered: Passing Values from Date Picker/Select Field to URL Query - How?
Hello!
I'm using Sencha Touch 2 with Sencha Architect 2 to build a webapp to help Portuguese people check their train times. I have a webservice in which I send data from the form in the app. E get the app to send the departure and arrival values, but not the ones from the date picker and the select field. Something must be wrong in my code, but I can't seem to figure out what.
So far, this is my code for the search view:
If I perform a query now, I get the url "http://poucaterra.joaodias.me/searchData/getData.php?departure=cityA&arrival=cityB", which is not enough to perform a sucessfull query.Code:Ext.define('MyApp.view.Pesquisar', { extend: 'Ext.form.Panel', alias: 'widget.pesquisar', config: { id: 'pesquisar', method: 'get', standardSubmit: true, submitOnAction: true, url: '', items: [ { xtype: 'fieldset', title: 'Estações', items: [ { xtype: 'textfield', id: 'departure', itemId: 'departure', label: 'Origem', name: 'departure', placeHolder: 'Estação' }, { xtype: 'textfield', id: 'arrival', itemId: 'arrival', label: 'Destino', name: 'arrival', placeHolder: 'Estação' } ] }, { xtype: 'fieldset', title: 'Data e Hora', items: [ { xtype: 'datepickerfield', id: 'day', itemId: 'day', label: 'Data', name: 'data', value: { year: 2012, month: 6, day: 16 }, autoComplete: true, placeHolder: 'aaaa-mm-dd', dateFormat: 'Y-m-d', picker: { useTitles: true, dayText: 'Dia', monthText: 'Mês', slotOrder: [ 'year', 'month', 'day' ], yearFrom: 2011, yearText: 'Ano', doneButton: 'Inserir', cancelButton: 'Cancelar' } }, { xtype: 'selectfield', id: 'hour', itemId: 'hour', label: 'Hora', name: 'hour', placeHolder: 'Hora de Partida', options: [ { text: 'Qualquer Hora', value: 'qq' }, { text: '0h00', value: '0' }, { text: '1h00', value: '1' }, { text: '2h00', value: '2' }, { text: '3h00', value: '3' }, { text: '4h00', value: '4' }, { text: '5h00', value: '5' }, { text: '6h00', value: '6' }, { text: '7h00', value: '7' }, { text: '8h00', value: '8' }, { text: '9h00', value: '9' }, { text: '10h00', value: '10' }, { text: '11h00', value: '11' }, { text: '12h00', value: '12' }, { text: '13h00', value: '13' }, { text: '14h00', value: '14' }, { text: '15h00', value: '15' }, { text: '16h00', value: '16' }, { text: '17h00', value: '17' }, { text: '18h00', value: '18' }, { text: '19h00', value: '19' }, { text: '20h00', value: '20' }, { text: '21h00', value: '21' }, { text: '22h00', value: '22' }, { text: '23h00', value: '23' } ] } ] }, { xtype: 'button', handler: function(button, event) { var form = Ext.getCmp('pesquisar'); form.submit({ url: 'http://poucaterra.joaodias.me/searchData/getData.php', method: 'GET', success: function (frm, res) { alert('Form submitted: '); }, failure: function (frm, res) { alert('Form no submit!'); } }); }, itemId: 'submit', text: 'Consultar' } ] } });
I need to get "departure", "arrival, but also "day" and "hour".
Is there something extra I need to setup for date selectors and select fields?
Help, please
-
17 Jun 2012 9:32 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
The reason is because of your use of standardSubmit. The <input> fields for the datepickerfield and selectfield are disabled so a standardSubmit form will not submit these values. Remove standardSubmit config and it will try to include them in.
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.
-
17 Jun 2012 10:07 AM #3
Hey, thanks, Mitchell
You're the man!
Now I'm getting "XMLHttpRequest cannot load http://poucaterra.joaodias.me/search...=1339956189118. Origin http://localhost is not allowed by Access-Control-Allow-Origin."
How can I solve this?
-
17 Jun 2012 10:43 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
enable-cors.org
Your server needs to support CORS to do cross-origin requestsMitchell 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.
-
18 Jun 2012 4:58 AM #5
Ok, I think I've accomplished that, by putting an htaccess file with "".
Now I get Uncaught Error: You're trying to decode an invalid JSON String: Error: Departure And Arrival Info Are Required
It seems that now, without the StandardSubmit active, and CORS installed, my query doesn't send any query parameters. I get that "Error: Departure and Arrival Info Are Required" when i don't send any query parameters.
I think I have it installed, because i get
when i performCode:HTTP/1.1 200 OK Date: Mon, 18 Jun 2012 12:47:04 GMT Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Vary: User-Agent,Accept-Encoding Access-Control-Allow-Origin: * Content-Type: text/html;charset=ISO-8859-1
I'm sorry to bother with all theses questions, but I'm kinda noob with all this.Code:curl -I poucaterra.joaodias.me/

-
18 Jun 2012 5:05 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
You need to response with somethign like
Code:{ "success" : true }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.
-
18 Jun 2012 5:08 AM #7
what do you mean?
Because I have that in my submit button...
Is this it?Code:{ xtype: 'button', handler: function(button, event) { var form = Ext.getCmp('pesquisar'); form.submit({ url: 'searchData/getData.php', method: 'GET', success: function (frm, res) { alert('Formulário inserido com sucesso!'); }, failure: function (frm, res) { alert('Erro.Formulário inserido sem sucesso'); } }); }, itemId: 'submit', text: 'Consultar' }
Sorry, I'm all confused...
-
18 Jun 2012 5:18 AM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
respond from the server
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.


Reply With Quote