0

I am trying to write a small documentation tool to be used from the browser. It would need to fetch source code files from a web server. What would be the appropriate way to fetch files from JavaScript itself and then read them so they can be parsed ? The file to be fetched is on a different web server.

thanks in advance, vivekian

1 Answer 1

1
  1. Use some sort of ajax framework (or XmlHttpRequest) that would read a file, parse it and display it.
  2. You'll have to create a proxy to that other server. Otherwise you're going to run into security exceptions.

Given your main url http://www.x.com/help.html, and the source files that are located at http://www.x321.com/src/, you're going to create a proxy at http://www.x.com/proxy/ to http://www.x321.com/src/

Sign up to request clarification or add additional context in comments.

4 Comments

What would be the code which is to be written for the redirection to take place ? Does XmlHttpRequest do this transparently ?
This page has some solutions to the ajax proxy problem: developer.yahoo.com/javascript/howto-proxy.html
It depends on your web server - apache supports mod_proxy (httpd.apache.org/docs/1.3/mod/mod_proxy.html). I'd be surprised if your web server of choice wouldn't support proxies.
Also realized that jQuery lets you make cross domain calls docs.jquery.com/Ajax/jQuery.getScript#urlcallback

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.