I have PHP up to 5.4, Perl 5.8, C and Python available server-side.
So basically I have JavaScript client-side and I'm generating a string. I'd like to save this string server-side.
I know how to load a string from a file in the server with XMLHttpRequest. (削除) But I don't like the idea to use a file for just storing a string even if it's a big one. (削除ここまで)
So what I'm looking is an example from a string which goes from Javascript to PHP (or something available for me) and back from PHP to JavaScript.
If it does not involved MySQL it is better (I just want to save a string). I have nothing about jQUERY but I'm not planning to look into it right now.
EDIT 1 : To precise what I need, the user will connect to the website play with the JS application and in the middle save some simple stuff (the string). I want that afterward when he'll come back (or another user) to the website he can get his stuff back.
EDIT 2 : since it cannot be done as nnnnnn says in the comment. I changed the question to :
I'd like to save a string during the use of a JS application and restore it for the next user.
EDIT 3 : I'm looking for a simple example for saving the string in a file, as no other solution is feasible.
-
If you don't want to save to a file or a database where do you expect the string to be stored?nnnnnn– nnnnnn2013年02月13日 05:49:53 +00:00Commented Feb 13, 2013 at 5:49
-
I am kind of a real beginner in this, I used to have a C# program and ASP.NET on a server which was doing this. I was passing integer, string from one to the other. I was guessing this was possible between JS and PHP... guess I'm wrong. I'll edit my question.mthpvg– mthpvg2013年02月13日 05:52:31 +00:00Commented Feb 13, 2013 at 5:52
-
You can pass a value from JS to PHP, but your question talks about "saving" a string, which implies storing it indefinitely for later use. Perhaps you could be more clear about what you want to use this string for?nnnnnn– nnnnnn2013年02月13日 05:56:48 +00:00Commented Feb 13, 2013 at 5:56
-
you can store it into user sessions .. if you have one.syrkull– syrkull2013年02月13日 06:09:22 +00:00Commented Feb 13, 2013 at 6:09
-
I edit my questions, not precise enough, thks. So it has to be available to any users. The idea is that users add some contents and I want to be able to see it.mthpvg– mthpvg2013年02月13日 06:17:07 +00:00Commented Feb 13, 2013 at 6:17
2 Answers 2
If I understand correctly:
- send needed to server and save it to some temporary place (file, db, whatever)
- next load, ask via ajax if there is any change or data saved
- if so, load them
- if data are javascript sode, you can use eval() code
- Another, quite dirty solution is use cookie data
- You cannot expect that supported features in new browsers are supported in old ones as well - savind localy is not possible.
As per my understanding, you want to share data between user. So that, you are sending information to the server and server is responsible to give the same data later. And you dont want to use file as well as database. Session is not suitable to keep large data.
Then, An alternate solution is store your data in Memcache server. This is more suitable in your case. But you have to remember one thing about Memcache, That is, Memcache is not persistent storage. But you can increase Memcache flushing interval as much as you want.
Note: Memcache is RAM consuming process.