Javascript access text file on a different server

Hi!

This is my first post here. Thanks in advance for your help.

I need to populate a div’s innerHTML with a string from a text file on a different server, and possibly write back a string to another text file on that same server.

I’m a rusty ASP.Net/C# programmer, but I’m only now learning javascript. I’m really interested in learning client-side programming so I can be more full stack.

project requirements:

  1. I need to modify a webpage to read a text file on a different server and put the string into a div’s innerHTML. This will be done on page load.
  2. I need the same webpage to write a string to another text file on that same server. This will be done on a button click event.
  3. I cannot do it server side.

given:
The webpage resides on Server-A.
The text files are on Server-B.
Server-A and Server-B are at different hosting companies.

questions:
Can I (should I) use http or ftp or some other protocol for accessing Server-B from the webpage?
AJAX?
Do I need to write a web service on Server-B?

Thanks in advance, I really appreciate it…
Brad

Hi if you go for a simple AJAX request you will run into CORS issues. I suggest taking a look at it : https://enable-cors.org/

Complete list of answers:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.