1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    25
    Vote Rating
    0
    sbk099 is on a distinguished road

      0  

    Default Unanswered: AJAX Requests behaves differently in Browser and Emulator

    Unanswered: AJAX Requests behaves differently in Browser and Emulator


    Hi,

    I am testing my ST2 App in Browser and Emulator. The App runs smooth on Browser but not on Emulator. The Ajax Requests the app makes have different behaviors in each case.

    On Remote Debugging(using Weinre), I found that HTTP Authentication Headers in case of Emulator is different from that in Browser.


    Emulator(**Remote Debugging) :-
    Emulator_Error.jpg

    Browser:-
    Browser.jpg

    The server requests I'm making requires basic authentication, and the Ajax Requests through Browser sends the proper auth header, but the Ajax Requests through Emulator do not include the auth header and and the server rejects the request with a 401(Unauthorized) error.

    Code:
    Ext.Ajax.request({
    				
    			
    				url: "http://tdcvqaportal.inservices.tatamotors.com/ytd_get_week/weekbydate/"+sYear+sMonth+sDate,
    				
    				
    				
    				withCredentials: true,
    				username: "...",
    				password: "...",
    
    
    				success: function(response, opts){
    					console.log("Success");
    				
    					Ext.ComponentQuery.query('#datePanel')[0].setHtml(response.responseText);
    					Ext.Msg.alert('Week by Date ', response.responseText);
    				},
    				failure: function(response, opts){
    					console.log("Failure");
    				
    					Ext.Msg.alert('Error', response.statusText+"</br>"+response.responseText);
    				}
    				
    			});

    Any Ideas... What's going wrong??!!

    Thanks In Advance

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,978
    Vote Rating
    132
    Answers
    334
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    On the emulator are you testing in the browser or is your application packaged?
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    25
    Vote Rating
    0
    sbk099 is on a distinguished road

      0  

    Default


    Application is packaged... I have installed the apk in the emulator and then I'm remote debugging it

  4. #4
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,978
    Vote Rating
    132
    Answers
    334
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    If you have packaged with cordova you have to whitelist the domain.
    http://docs.phonegap.com/en/3.4.0/gu...telist%20Guide
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  5. #5
    Sencha User
    Join Date
    Jan 2013
    Posts
    25
    Vote Rating
    0
    sbk099 is on a distinguished road

      0  

    Default


    I have packaged the app using sencha cmd 3.0.0.250.

    So please suggest... how to whitelist the domain in this case...

  6. #6
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,978
    Vote Rating
    132
    Answers
    334
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    You will have to use CORS in that case. Check out the following blogpost:
    http://nelm.io/blog/2011/11/cors-with-sencha-touch/
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  7. #7
    Sencha User
    Join Date
    Jan 2013
    Posts
    25
    Vote Rating
    0
    sbk099 is on a distinguished road

      0  

    Default


    Packaging with an older version of Sencha Cmd might be the cause of this problem...

    Now I used the latest Sencha Cmd(4.0.2.67) and added a statement in Ajax Request-

    useDefaultXhrHeader: false,

    and everything was perfectly OK...

Thread Participants: 1

Tags for this Thread