I made a function where I am sending JSON. Then I used console.log
to view it. My code is
function json($data) {
console.log($data);
}
json({
"first_name": "First Name",
"last_name": "Last Name",
"phone": "Phone",
"orgname": "Organisation Name",
"email": "Email",
"1": "Sign-up Date"
});
In the console.log($data);
I receive the output like this:
{
1: "Sign-up Date",
first_name: "First Name",
last_name: "Last Name",
phone: "Phone",
orgname: "Organisation Name",
email: "Email"
}
However I need it like this
{
first_name: "First Name",
last_name: "Last Name",
phone: "Phone",
orgname: "Organisation Name",
email: "Email",
1: "Sign-up Date"
}
The problem is that instead of console.log
I'm actually using this code:
$.each($data, function(index, value) {
$(".custom_fields_with_names").append('<option value="' + index + '">' + value + '</option>');
});
and am getting the options in the wrong order (with "1" coming first).