HI Guys,
Complete n00b with JS.
i am building a phonegapp app for my sms site and need a bit of help.
when a user has correctly entered their username and password i have some json returning with their API key.
I want to save the API key and allow the next page to store it so they can send a sms.
code on the login page
<script>
$("#callAjaxForm").on("submit", function(e){
var $inputs = $('#callAjaxForm :input'),
values = {};
$inputs.each(function() {
values[this.name] = this.value;
});
$.ajax({
type : "POST",
url : "http://www.mysite.co.uk/login.app.php",
data: values,
success: function(data, status){
var obj = (data[0]);
if (obj.error == true) {
$("#result").html(obj.message);
$("input[type=text]").val("");
}
if (obj.error == false)
{
myhash = JSON.stringify(obj.message);
localStorage.setItem(name, myhash);
window.location.replace("sendsms.html");
}
}
});
return false;
});
</script>
next page has
<script>
var myhash2 = storage.getItem(myhash);
console.log (myhash2);
if (myhash2 == "")
{
alert ("No Hash");
} else
{
alert (myhash2);
}
</script>
Can any one suggest a way to store the obj.message which will have their API key so it can be passed to the next page?