Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
how to make json key value pair using two var

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!