View Full Version : POST to ASPX Web Service

9 Apr 2013, 10:30 AM
Hi, I'm new to sencha and development in general.

I developing a login for an app and I need to send a Form POST to a aspx Web Service but it seems to be something wrong with my code.

I used an example from miami coder and I found that I cannot use:


because of Cross Domain security concerns it return and error but while doing some research and bumping my head to the wall I found that I need to use:


Changing the request code returned me a Warning instead of an error on Google Chrome console

Resource interpreted as Script but transferred with MIME type text/html: "https://Site.aspx?e=e&p=p&callback=Ext.data.JsonP.callback1&_dc=1365531609125 (https://cloud.columbiaco.edu/Integrations/Authenticate.aspx?e=e&p=p&callback=Ext.data.JsonP.callback1&_dc=1365531609125)". sencha-touch.js:12400 (http://localhost/~Mori/Columbiaco/touch/sencha-touch.js)

After this the
Ext.data.JsonP.request does not enter to the Success anonymous function options.

onLogInCommand: function (view, e, p){
//console.log('Username: ' + e + '\n' + 'Password' + p);

var me = this, loginform = me.getLoginform();

if (e.legth === 0 || p.length === 0){
loginform.showSignInFailedMessage('Favor de entrar credenciales');

xtype: 'loadmask',
message: 'Conectando...'

url: 'https://Sites.aspx',
method: 'POST',
e: 'e',
p: 'p'
success: function (response){
console.log('Username: ' + e + '\n' + 'Password' + p);
var loginResponse = Ext.JSON.decode(response);

if (loginResponse.success != 0){
console.log('no igual a 0');
me.sessionToken = loginResponse.sessionToken;
} else {
console.log('igual a 0');
failure: function(response){
me.sessionToken = null;
me.signInFailure('Login failed. Please try again later.');

Thanks fot any help you could provide

9 Apr 2013, 3:47 PM
You can't do a post because of how JSONP works.

A common solution is to do an Ajax request to your own server and then have your server proxy the call to the remote server.

9 Apr 2013, 5:29 PM
hi evant, thanks for replying,

If I understood right,

I need to make the Ajax.request to a script containing a proxy call inside myApp so I can get the values I need for loggin in?


before reading the reply I changed the POST to GET (server side and app side) and manage to get response from the server (it returned my values) but the success function did not activated.

11 Apr 2013, 6:41 PM
I managed to get around from my last error by changing the headers of the aspx site. But know I am getting a unexpected token : from the site and I don't even know what to do so this code get into the success function :(

need a little more help, please. I have been doing this since last saturday
edit - update

I managed to get the response json from the site using http://docs.sencha.com/touch/2-1/#!/api/Ext.data.proxy.JsonP

but i cannot read the json using Ext.JSON.decode(response.responseText). Is there's a way that i could decode the json string?