Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  198] [ 6]  / answers: 1 / hits: 18619  / 9 Years ago, mon, december 7, 2015, 12:00:00

I have the following ajax call and the json feed it returns. how do I get the value of the data object i.e. FRI from the feed using jquery?



$.ajax({
url: query,
type: GET,
dataType: json
success: function(data) {
var day = // get data value from json
$(#Day).val(day);
}
});

{
name:workdays,
columns:[
day
],
data:[
[
FRI
]
]
}


* update *



What would be the syntax be if the results were returned as jsonp as follows, how can you extract the value 'FRI' :



import({
Results:{
work_days:{
empid:100010918994,
day:FRI
}
}
});

More From » jquery

 Answers
6

This is just JavaScript, not jQuery.



var data = {
name:workdays,
columns:[
day
],
data:[
[
FRI
]
]
}

data.data[0][0]; //FRI


UPDATE



var obj = {
Results:{
work_days:{
empid:100010918994,
day:FRI
}
}
}

obj.Results.work_days.day //FRI

[#64142] Friday, December 4, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yaquelina

Total Points: 517
Total Questions: 101
Total Answers: 96

Location: Egypt
Member since Tue, Jul 6, 2021
3 Years ago
yaquelina questions
;