/    Sign up×
Community /Pin to ProfileBookmark

How do I save and retreive variables with Jquery?

Hey guys, thanks for helping me learn to save data from a form to a variable. I am working on my text game for learning purposes and and moving right along. Now it saves the users name and addresses the user by it. But my game is going to need to save and retrieve variables from a file. For now I want to save them locally on my computer. Of course I realize that if its going on the web, which it eventually will for my portfolio, it will need to save and retreive information off the server. Is it similar? Is there a free web hosting service that can do this right now that I can use temporarily? Ideally it would work with a database but I think I need to spend money for that so we wont do that right at this moment. How would one save the variable in a local file and also retrieve it once it is stored. I need to do it the jquery way. I find jquery to be easier to understand. I have a feeling this is going to involve Ajax. Please point me in the right direction. Here’s my code so far :

// mycode
<html>

<head>
<title> Legend of the Dragonstone </title>

<head>

<body>
<header>

<script src = “http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js“> </script>

<script>

$(document).ready(function() {

function welcome() {
$(“header”).append(“<p>Please enter your name.</p>”);
$(“#button”).click(function(){
$(“p”).hide();
var name = $(“#text”).val();
$(“header”).append(“Welcome ” + name +”.”);
});

};

welcome();

});

</script>

</header>

<body>

<input type=”text” id=”text”>
<p></p>
<input type=”button” value=”go” id = “button”>

</body>

</html>

//mycode

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meJun 11.2013 — you can use a google spreadsheet, or a free hosting plan, many of which provide PHP, which can save to a flat file or DB.
Copy linkTweet thisAlerts:
@matth1980authorJun 11.2013 — Google spreadsheet sounds interesting can somebody tell me how to do it in Jquery.
×

Success!

Help @matth1980 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...