2

Im new to Jquery and Javascript and im wondering how can i read information from a text file stored on my server and write back to this file again afterwards? I couldn't find much information after googling the problem

I would also like to read in the data line by line and store it in an array, is this possible?

Thanks, Matt

Matt
  • 31
  • 2

4 Answers4

0

I think you want to use some server side programming. If you want the data on the client, you can use javascript or jquery using some ajax solution.

Bas Slagter
  • 9,831
  • 7
  • 47
  • 78
0

You can read the file if server allows to get it via http but you cannot write to it

Read file can be done by simply $().load(url)

vittore
  • 17,449
  • 6
  • 44
  • 82
0

You could use a RESTful API in order to achieve this. Use HTTP GET (jQuery/AJAX) to get the contents of a file, edit what you wish, and use a HTTP PUT (jQuery/AJAX) to write the changes back to the server.

Norman Joyner
  • 955
  • 6
  • 12
0

Read information - yes via ajax call. The javascript will get the text from the page - whatever it is html/php/asp and return it to the calling page.

Read line by line - it is possible if you write it yourself. There is no built-in function for this. But then the text should be divided by lines.

Write back - JavaScript can`t do it by itself. You need an ajax and serverside.

Bakudan
  • 19,134
  • 9
  • 53
  • 73