0

I am getting the following error when i try to execute send some values via SenchaTouch to the web service. What does this mean, and how can i solve this? The remaining of my code can be found at this SO post

XMLHttpRequest cannot load http://testWebService/service/. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

note: I found this link, but it still didn't help.

user1315906
  • 3,374
  • 8
  • 30
  • 43
  • possible duplicate of [XMLHttpRequest cannot load http://www.-** Origin http://localhost:59382 is not allowed by Access-Control-Allow-Origin](http://stackoverflow.com/questions/5980200/xmlhttprequest-cannot-load-http-www-origin-http-localhost59382-is-not-a) – Saurabh Gokhale Apr 26 '12 at 15:57

3 Answers3

1

This is the browser blocking a cross domain XMLHttpRequest. You will need to either run a local copy of the web service on localhost, or upload your application to the TestWebService domain.

gcochard
  • 11,408
  • 1
  • 26
  • 41
  • I am allowed to access the TestWebService domain. I am in my LocalHost, so is there anyway i could send request from localhost ? – user1315906 Apr 26 '12 at 16:00
  • You can start up a local apache/PHP server and create a proxy that fetches the data you want to load from the service, and displays it. Since that runs on localhost, you would not be in violation of the cross domain scripting rules. – gcochard Apr 26 '12 at 16:02
  • I am a beginner, Can you point me to a tutorial to get this done ? Help – user1315906 Apr 26 '12 at 16:03
  • This may help: [jsonp with sencha touch not working](http://stackoverflow.com/questions/5869239/jsonp-with-sencha-touch-not-working) – gcochard Apr 26 '12 at 16:14
  • That example didn't help. If you have any other links, tutorials please help me out. Thank you – user1315906 Apr 26 '12 at 16:31
1

If you are planning to run your application as a web application, you have to make sure your web service is in the same domain as your application.

Try this if you are planning to deploy sencha touch through phonegap but want to debug on your browser.

Using chrome, to disable Cross-site scripting security: Disable same origin policy in Chrome

Or using safari : (for this method http://localhost won't work)

  1. Open the file locally on safari.(cmd+o and select the html file you wanna run)

Safari does not have XSS security for local files.

Hope it helps.

Regards, Steve0hh

Community
  • 1
  • 1
steve0hh
  • 637
  • 6
  • 15
  • Thank you your answer it helped me to some extent. I am beginner, so can you suggest me a gook book to learn sencha touch, phone gap and to run application on device using Xcode. I am trying sencha for a week, and having a hard time with it:S – user1315906 Apr 28 '12 at 15:02
1

See enable-cors.org, to enable Cross-Origin Resource Sharing.

Something else
  • 211
  • 2
  • 7