1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    4
    Vote Rating
    0
    jmorillo is on a distinguished road

      0  

    Default Unanswered: POST to ASPX Web Service

    Unanswered: POST to ASPX Web Service


    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:
    Code:
    Ext.Ajax.request
    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:

    Code:
    Ext.data.JsonP.request
    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".sencha-touch.js:12400

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

    Code:
    	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');
    			return;
    		}
    		
    		loginform.setMasked({
    			xtype: 'loadmask',
    			message: 'Conectando...'
    		});
    		
    		Ext.data.JsonP.request({
    			url: 'https://Sites.aspx',
    			method: 'POST',
    			params:{
    				e: 'e',
    				p: 'p'
    			},
    			success: function (response){
    			console.log('Username: ' + e + '\n' + 'Password' + p);
    				console.log('Entro-Success');
    				var loginResponse = Ext.JSON.decode(response);
    				
    				if (loginResponse.success != 0){
    				console.log('no igual a 0');
    					me.sessionToken = loginResponse.sessionToken;
    					me.logInSuccess();
    				} else {
    				console.log('igual a 0');
    					me.logInFailure(loginResponse.message)
    				}
    			},
    			failure: function(response){
    				me.sessionToken = null;
    				me.signInFailure('Login failed. Please try again later.');			
    			}
    		});
    	},
    Thanks fot any help you could provide

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,814
    Answers
    453
    Vote Rating
    607
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    4
    Vote Rating
    0
    jmorillo is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    4
    Vote Rating
    0
    jmorillo is on a distinguished road

      0  

    Default


    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/#!/...ta.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?

    thanks

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi