How to create and send data object/resource through a function?

I am not an experienced developer with JQuery/Javascript. Currently I am having an issue maintaining same contents through out various processes without querying database again and again. With JQuery/Javascript, I am sure this is easy although I do not know the best way of doing it. Below is an example of what I want:

//SCRIPT 1

//......Get  some data from database eg:

var fname = "Donald";
var lname = "Trump";
var user_id = 1;
var address = "White House";

resource = fname, lname, user_id, address;

<a href="#" onclick="view('+resource+');">Post</a>

//END SCRIPT 1

//SCRIPT 2
// ....................Now on receiving function, can I do something like this?
function view(resource) {

$fname = resource.fname;
$lname = resource.lname;
$address = resource.address;
$user_id = resource.user_id;

}

while a valid JS statement, this is not an object, as you are expecting.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.