I hesitated asking a this question in fear of getting the all feared down-vote, but after many searching and countless hours of typing, I must give in.
I'm just trying to get these values from a json object (ie 37
and exampleoffice
):
{"officeId":37,"officeName":"exampleoffice"}
I have tried data[0]
, data.officeId
, data[0][officeId]
, for loop, $.each(data, function(i, item){})
...
I would appreciate if someone could help me and make this headache go away!
jquery:
$(document).on("click", "#addOffice", function() {
var officeadd = $('#officeAddForm').serializeArray();
console.log(officeadd);
$.ajax({
url: 'officeadd.php',
type: "POST",
data: officeadd,
success: function(data) {
console.log(data);
$('#officecontrolgroup').append('<input type="radio" name="office" id="' + data.officeId + '" value="' + data.officeId + '"/><label for="' + data.officeId + '">' + data.officeName + '</label>').trigger('create');
$('#officecontrolgroup').controlgroup("refresh");
$( "#deliveryInstructions" ).trigger( "updatelayout" );
}
});
return false;
});