1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      1  

    Default Answered: Origin http://localhost is not allowed by Access-Control-Allow-Origin

    Answered: Origin http://localhost is not allowed by Access-Control-Allow-Origin


    SALAM all.
    when i'm tring to execute Ext.Ajax.request({ function, ann error appear. i'm using google chrom to test my app. here is my code:
    Code:
    
    
    Code:
    varurtemp = Ext.getCmp('Login').getValue()+"/"+Ext.getCmp('password').getValue();
    Ext.Ajax.request({
    
    
      url: 'http://localhost:8732/log/log/'+urtemp,
      success : function(response) {
    
      Ext.getCmp('res').setValue(response.responseText);
      var user = eval('('+ response.responseText+ ')'); 
       App.variable = user.clientID;
       var nv = user.clientNOM;
       var pr = user.clientPRENOM;
     if(nv !== "null") {
    // console.log(App.variable);
      		Ext.Msg.alert("Bienvenue Monsieur",pr+" "+nv);
                    Ext.redirect('Banking/compte');
                    window.location = redirect;
          }
    else {Ext.Msg.alert("Mot de passe ou login incorrecte","veuillez reeseyer");}
      },
      failure: function(response) {
    	  Ext.getCmp('res').setValue(response.status);
     }
     });

    im using google chrom to test my app.
    the error is
    [COLOR=red !important]Failed to load resource: the server responded with a status of 405 (Method Not Allowed) http://localhost:8732/log/log/admin/...=1338212400945[/COLOR]
    [COLOR=red !important]XMLHttpRequest cannot load http://localhost:8732/log/log/admin/...=1338212400945. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

    [/COLOR]

    and the response.status is 0
    and even i test it on an Android Emulator, i have the same response.status = 0
    how can i fix it. thank you.
    [COLOR=red !important]
    [/COLOR]

  2. Hi, in the Android Emulator you dont have access to localhost (http://127.0.0.1) .
    http://stackoverflow.com/questions/6...droid-emulator

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You are trying to work with CORS (cross origin resource). Does your server support CORS?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    SALAM.
    thank you for your response. i fixed it but adding in the shortcut of google chrome : --disable-web-security
    and adding to IIS : "Access-Control-Allow-Origin" "*" and now it's work correctly in my browser.
    but my target is to build a mobile app, so i tested it on an Android emulator, but it's failed to consume my web service. i work on localhost. ==> the response.status is "0". I tried another thing, i put Ext.data.jsonp instead of Ext.ajax.request, without success. have you any idea to correct my code.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You switched to JsonP but did you update your response to be valid?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  6. #5
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    how can i update it ?
    my response is a json file
    Code:
    {"LOGIN":"admin","PASSWORD":"admin","clientADRESSE":"zouhour","clientCODE":"9876","clientID":"1234","clientNOM":"jouini","clientNUMTEL":"21212121","clientPRENOM":"zied","comptes":[],"demandes":[]}
    there is a modification should be i do ?

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    JsonP requires the JSON to be wrapped in a callback function which the name of that function is passed as the callback parameter in the request.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  8. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Answers
    2
    Vote Rating
    0
    nickyh62 is on a distinguished road

      0  

    Default


    Could you perhaps give an example of the format expected when the json response is wrapped within the callback function please mitchell?

  9. #8
    Sencha User
    Join Date
    Aug 2010
    Posts
    303
    Answers
    3
    Vote Rating
    3
    steve1964 is on a distinguished road

      0  

    Default


    Hi, in the Android Emulator you dont have access to localhost (http://127.0.0.1) .
    http://stackoverflow.com/questions/6...droid-emulator

  10. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Answers
    2
    Vote Rating
    0
    nickyh62 is on a distinguished road

      0  

    Default


    Quote Originally Posted by nickyh62 View Post
    Could you perhaps give an example of the format expected when the json response is wrapped within the callback function please mitchell?
    Worked it out, for anyone with a similar query the wrapped json response should take the format:


    Ext.data.JsonP.callback1({Your JSON})

    Note the callback part is incremented per subsequent call and will need to be handled by the server side web service when generating a response, i.e. callback2, callback3 and so on.

  11. #10
    Sencha User
    Join Date
    Jun 2013
    Posts
    14
    Vote Rating
    12
    NakedSword will become famous soon enough

      1  

    Default Help

    Help


    Quote Originally Posted by zied jouini View Post
    SALAM.
    thank you for your response. i fixed it but adding in the shortcut of google chrome : --disable-web-security
    and adding to IIS : "Access-Control-Allow-Origin" "*" and now it's work correctly in my browser.
    but my target is to build a mobile app, so i tested it on an Android emulator, but it's failed to consume my web service. i work on localhost. ==> the response.status is "0". I tried another thing, i put Ext.data.jsonp instead of Ext.ajax.request, without success. have you any idea to correct my code.

    hi,
    i am also facing same problem canyou help me by adding steps how did you do it??
    help me

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