I am trying get json values from a database using an ajax jquery with php. My code.... Currently i didn't get any error and i had tried already How do I return the response from an asynchronous call? this link before posted over here. i didn't get data in return value while i have added using it in ajax,
--------------------code 1-------------------
$.ajax({
type: "Post",
url: site_url + "admin/venue_booking_list/" + val,
//dataType: 'html',
data: {
van_id: val
},
async: true,
cache: false,
//dataType: 'json',
success: function(data) {
return [{
"title": "Booked",
"start": "19-01-2016 08:00:00",
"end": "19-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "19-01-2016 08:00:00",
"end": "19-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "04-01-2016 08:00:00",
"end": "04-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "01-01-2016 07:30:00",
"end": "01-01-2016 08:00:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "13-01-2016 07:30:00",
"end": "13-01-2016 08:00:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}];
}
});
}
-------------code 2 ----------------------
$.ajax({
type: "Post",
url: site_url + "admin/venue_booking_list/" + val,
//dataType: 'html',
data: {
van_id: val
},
async: true,
cache: false,
//dataType: 'json',
success: function(data) {
// removed code
}
return [{
"title": "Booked",
"start": "19-01-2016 08:00:00",
"end": "19-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "19-01-2016 08:00:00",
"end": "19-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "04-01-2016 08:00:00",
"end": "04-01-2016 08:30:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "01-01-2016 07:30:00",
"end": "01-01-2016 08:00:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}, {
"title": "Booked",
"start": "13-01-2016 07:30:00",
"end": "13-01-2016 08:00:00",
"backgroundColor": "#12CA6B",
"textColor": "#FFF"
}];
In the first of the 2 code snippets when data is retrieved from the database it doesnt show in console bar as Object json, as in the following image.
How can I get a result like the second image, where there is static code in the js file, as shown in code2?
Please Help