json is totally new to me how to write an ajax_callback function for agile carousel to work in wordpress? Below is the jason data format that I need to write as php arrays for it could be parsed by $.getJSON() function.
[{
"content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='slides/slide_3.png' alt='Bike'></a><a class='caption' href='#'></a></div>",
"content_button": "<div class='thumb'><img src='slides/f2_thumb.jpg' alt='bike is nice'></div><p> Place Holder</p>"
}, {
"content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='slides/slide_4.png' alt='Bike'></a><a class='caption' href='#'></a></div>",
"content_button": "<div class='thumb'><img src='slides/f2_thumb.jpg' alt='bike is nice'></div><p> Place Holder</p>"
}]
Or do I even have to convert the data into php arrays?
So I see you’re referring and attempting to recreate this example:
The carousel is being created using the data parameter in the JSON AJAX callback.
However,
carousel_data
requires a data object, it doesn’t require that it comes from a call to$.getJSON()
. Instead you could define the json object there, like:Even further, you can generate the necessary data in PHP, and then localise it using
wp_localize_script
, and WordPress will include it in the header:This should bypass all need for AJAX and custom requests.
However if you feel you must, look at the WP AJAX API here:
http://codex.wordpress.org/AJAX_in_Plugins
( it applies to themes too )