Intergrating agile carousel to wordpress: how to write the ajax_callback function

So I see you’re referring and attempting to recreate this example: <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/63304/agile_carousel.css”> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.js”></script> <script src=”agile_carousel/agile_carousel.a1.1.js”></script> <script> // Code used for “Flavor 2” example (above) $.getJSON(“agile_carousel/agile_carousel_data.php”, function(data) { $(document).ready(function(){ $(“#flavor_2”).agile_carousel({ // required settings carousel_data: data, carousel_outer_height: 330, carousel_height: 230, slide_height: 230, carousel_outer_width: 480, slide_width: 480, // end required settings transition_type: “fade”, transition_time: 600, … Read more

Pass data from wordpress to javascript in JSON

Try wrapping your array in json_encode(): function add_map_data() { $objName = “MapData”; $array = array( “MapViewLatitude” => “51.505”, “MapViewLongitude” => “-0.09”, ); wp_enqueue_script( ‘mapdata’, get_bloginfo(‘template_url’).’/custom/map.js’, null, null, false ); wp_localize_script( ‘mapdata’, $objName, array(‘my_arr’ =>json_encode($array))); } add_action( ‘wp_enqueue_scripts’, ‘add_map_data’); Next step is to parse the JSON string back to a JSON object in JavaScript so: //first … Read more

Jetpack API for WordPress Network

I answered my own question. The slash in the URL messes up the API call. However urlencoding the URL will get around it. IE: $context = stream_context_create( $options ); $site = urlencode(“subdomain.example.com/site1″); $response = file_get_contents( ‘https://public-api.wordpress.com/rest/v1/sites/’ . $site .”https://wordpress.stackexchange.com/”, false, $context );

JSON – Permission Error?

Your problem is that you are checking for nonce and the nonce is stale. It is hard to make a specific comment about the need of using nonce in your case, but in general nonces should be used only for data submission not query.

AngularJS with route and JSON API

Doublecheck if there’s a “nobase” error in your console. If so, according to the AngularJS documentation, and fix.io (credits for this answer go to the author of that post) the base tag is to the rescue. <html ng-app=”app”> <head> <base href=”https://wordpress.stackexchange.com/angular-wp/”> <title>AngularJS Demo Theme</title> <?php wp_head(); ?> Please note the “/angular-wp/” is the sub-context in … Read more

How to get those data using with ajax json?

There are two methods to access the object. 1. Ajax response. $.ajax({ url:”your_file.php”, type : “POST”, data : your_data, dataType: “json”, success:function(data){ // Retrieve the object var result = data[0]; // Grab username from the object console.log(result[‘username’]); }, error:function(xhr){ alert(‘Ajax request fail’); } }); 2. Server side script $yourArray = array(); $yourJson = json_encode($yourArray); $userData … Read more