I have two var's
var a = result.master_id;
var b = result.session_name;
i want to create a json string to pass to ajax. i tried this
var userData = {'pid':a,'session' :b};
i'm storing this userData in a sessionStorage and sending to ajax . but i'm getting pid undefined error.
is this the right way to do this?
any help is appreciated. regards, newbie
You are using the right code to store into variable. Try to console variable to identify.
Example code given below:
let result = {
master_id: 1,
session_name: "Hardik"
}
var a = result.master_id;
var b = result.session_name;
var userData = {'pid':a,'session' :b};
console.log(userData);