I am trying to display the XNAT projects in a dropdown list; however the value for project id is being returned as undefined. My code is:
//populate the Project ID select
function populateProjectID() {
alert("Populate project ID: ");
$.ajax({
type: 'GET',
dataType : "json",
url: XNAT_URL+'data/archive/projects/?format=json',
xhrFields: {
withCredentials: true
},
headers: {
'Content-Type':'application/x-www-form-urlencoded',
},
success: function(response, status, xhr) {
var responseObjArray = response.ResultSet.Result;
alert("Populate project ID success: " + responseObjArray);
for(var obj in responseObjArray){
alert("responseObjArray[obj].project: " + responseObjArray[obj].project);
$('<option style="color:black>').text(responseObjArray[obj].project).appendTo('#projectName');
}
},
error: function(response) {
alert("Populate project ID error: ");
console.log(response)
}
});
}
The "alert("Populate project ID success: " + responseObjArray);" returns:
Populate project ID success: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The alerts "alert("responseObjArray[obj].project: " + responseObjArray[obj].project);" each return:
responseObjArray[obj].project: undefined
How can I get the value of the project ID to populate the drop down please?
should be