• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

saving data in JavaScript

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to make an application using JavaScript, and am trying to think of some clever ways to get around JavaScript's weak point, which is saving data to files.
(I just know someone is going to tell me that JavaScript was made on purpose not to save data files, therefore it is not a weak point. But I want to save information, so for me it's a weak point.)
One way to save data, is to have the program print out text onto the document, and then the user selects the text and copies it into a text file. Then, when the user wants to input text into the program, the user copies text from the text file and puts it into a text area in the document.
Another way to save data is to use cookies. But I read somewhere that cookies are quite limited in the amount of text that can be saved in them.
Anyone have any clever ideas?
One idea that I have involves having the program read the text off another document. Is there some way for a program to read the text printed directly onto a document(not printed in a text area)? Or is there some way for a program to read the entire content of a document, including HTML tags and scripts, and everything?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kevin Tysen:

(I just know someone is going to tell me that JavaScript was made on purpose not to save data files, therefore it is not a weak point. But I want to save information, so for me it's a weak point.)



Yup, I'm that someone. It's a strength; the last thing I want is anyone writing data to my system.

and then the user selects the text and copies it into a text file.



And just how many users do you think are going to put up with that?

One idea that I have involves having the program read the text off another document.



What other document? Where?

Another way to save data is to use cookies. But I read somewhere that cookies are quite limited in the amount of text that can be saved in them.



This is true.

Anyone have any clever ideas?



Store it on the server where it belongs. But I'm sure that's not what you want to hear. You're trying to use a hammer to flip pancakes.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to limit yourself to IE, you always have ActiveX.

Eric
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About reading the text off another document, what I mean is something like this. Suppose there is a web page made by someone else that I don't have access to edit, but I can read it of course. And the page looks like this:
<HTML><HEAD></HEAD><BODY>
Today's weather: rain
</BODY></HTML>

So I want my program to download this page (the content of which changes because the weather changes every day) and read the words "Today's weather: rain", and then parse it up, or whatever, and use the info in my page. That's what I mean.

About saving the data on the server, is there some way to do that only by using JavaScript, and not CGI? And can you read the data again?

The program I'm working on now, actually I wrote it already in Java, and I've been using it. But now I want to have other people use it too, but I don't think they will all want to download the JRE, so I want to use JavaScript, because virtually everyone has it already on their internet browsers.
Well, thank you for the helpful advice.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kevin Tysen:

So I want my program to download this page (the content of which changes because the weather changes every day) and read the words "Today's weather: rain", and then parse it up, or whatever, and use the info in my page. That's what I mean.



Assuming that the page is available from the same domain, you can use Ajax to read it in. If it's valid XML it will be easy to parse. if not, not so easy.

If the page is not hosted on the same site, you're out of luck again as you'll need a server-side cross-server proxy to obtain the document.

About saving the data on the server, is there some way to do that only by using JavaScript, and not CGI?



No.

but I don't think they will all want to download the JRE



No one needs to download a JRE in order to use a Java-powered site. The Java exists on the server, not the client. (Not talking about Applets here which is another matter orthogonal to this discussion).
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"No one needs to download a JRE in order to use a Java-powered site. The Java exists on the server, not the client."

Using a Java program on a server would be considered as 'using CGI', wouldn't it? The contract I have with my internet service provider lets me have a home page, but I can't write my own CGI scripts.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My next step would be to find a better provider. Seriously. You are trying to fly in a straight-jacket.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure exactly what you are trying to accomplish, but this article might be of some use to you.
Brad Neuberg's blog posting on Dojo.Storage

I haven't tried it yet myself, but it does claim to offer a solution for offline storage of data.
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic