this is what I am trying to do.
I have made a few .html pages with JavaScript code in it and hosted them on a Yahoo server.
Now when a clien
Due to policy restrictions browsers do not allow you to send XMLHttpRequest to domains different than the domain hosting the web page which in your case is Yahoo.
As others have commented, this doesn't work because of the browser security model.
You might be able to get around this with an entry in your hosts file.
First, assuming your app is on a yahoo.com domain, open your hosts file and add an entry like this
127.0.0.1 mylocalhost.yahoo.com
Then, in your pages, change your AJAX endpoint to http://mylocalhost.yahoo.com/myservlet/serverl1
I've never tested this, so I can't be certain it will work, but it might. If it does work, every user of this page will need to modify their hosts file like above
Note: your hosts file should be located at C:\WINDOWS\system32\drivers\etc\hosts
in windows, and at /etc/hosts
in *nix
Isn't this a cross-domain problem?
The local machine also needs a proxy set up that maps "http://localhost:8080/whatever" to the yahoo pages with your Ajax code. In order for the code to work, you must load it in the browser using the domain same domain that it tries to access.
I'm not sure how to do this with Tomcat (?), but one option is to use Apache to proxy both the Tomcat server and the Yahoo pages into the same location.
In Apache, this looks like:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
...
<IfModule proxy_http_module>
ProxyRequests off
ProxyPass /static http://yahoo.com/path
ProxyPass /myservlet http://localhost:8080/myservlet
</IfModule>
You would then load your HTML from localhost/static, and those pages would be able to make AJAX requests to localhost/myservlet.
Cross-site Scripting
You cannot access what is not on your domain, unless it is a Web Service returning XML or JSONP