SoundCloud working on WordPress JSON API

SoundCloud working on WordPress JSON API
ESPN
// Example JSONP request with jQuery
$.ajax({
url: “http://api.espn.com/v1/sports/news/headlines”,
data: {
// enter your developer api key here
apikey: “{7jwgjwpupg3nmbzan5k4umwq}”,
// the type of data you’re expecting back from the api
_accept: “application/json”
},
dataType: “jsonp”,
success: function(data) {
// create an unordered list of headlines
var ul = $(‘

    ‘);
    $.each(data.headlines, function() {
    var li = $(‘
  • ‘).text(this.headline);
    ul.append(li)
    });
    // append this list to the document body
    $(‘body’).append(ul);
    },
    error: function() {
    // handle the error
    }
    });
    ESPN Code End

    $(‘#’ + id + ‘ .content1’).bind(‘click’, function (e) {
    e.preventDefault();
    getContent(‘/function-demos/functions/ajax/data/content1.html’);
    });

    $(‘#’ + id + ‘ .content2’).bind(‘click’, function (e) {
    e.preventDefault();
    getContent(‘/function-demos/functions/ajax/data/content2.html’);
    });

    $(‘#’ + id + ‘ .content3’).bind(‘click’, function (e) {
    e.preventDefault();
    getContent(‘/function-demos/functions/ajax/data/content3.html’);
    });

    function getContent(filename) {
    $.ajax({
    url: filename,
    type: ‘GET’,
    dataType: ‘html’,
    beforeSend: function () {
    $(‘#’ + id + ‘ .contentarea’).html(‘‘);
    },
    success: function (data, textStatus, xhr) {

    if (filename == ‘/function-demos/functions/ajax/data/content3.html’) {
    setTimeout(function () {
    $(‘#’ + id + ‘ .contentarea’).html(data);
    }, 2000);
    } else {
    $(‘#’ + id + ‘ .contentarea’).html(data);
    }
    },
    error: function (xhr, textStatus, errorThrown) {
    $(‘#’ + id + ‘ .contentarea’).html(textStatus);
    }
    });
    }




    jQuery Function Demo – jQuery4u.com



    getContent('/function-demos/functions/ajax/data/content2.html');
    });

    $('#'+id+' .content3').bind('click', function(e)
    {
    e.preventDefault();
    getContent('/function-demos/functions/ajax/data/content3.html');
    });

    function getContent(filename)
    {
    $.ajax({
    url: filename,
    type: 'GET',
    dataType: 'html',
    beforeSend: function() {
    $('#'+id+' .contentarea').html('');
    },
    success: function(data, textStatus, xhr) {

    if (filename == '/function-demos/functions/ajax/data/content3.html')
    {
    setTimeout( function() {
    $('#'+id+' .contentarea').html(data);
    }, 2000);
    }
    else
    {
    $('#'+id+' .contentarea').html(data);
    }
    },
    error: function(xhr, textStatus, errorThrown) {
    $('#'+id+' .contentarea').html(textStatus);
    }
    });
    }

    },

    reset: function(id)
    {
    $('#'+id+' .contentarea').html('Content will appear here.');
    $('#'+id).hide();
    }
    }
    }
    }


    Demo: Using $.ajax() to load content without reloading the entire page.

    HTML content is held in separate files which are inserted below using AJAX. Note that it is also courtesy to show a loading image while the AJAX request is processing. Content 3 has a 2 second delay to simulate the loading image.

    Run Demo View Code

    Content will appear here.




    Microsoft Office 2010
    Fatal error: Call to a member function xpath() on a non-object in /home1/mylifeco/public_html/pricecutterstore.com/admin/models/api/affiliate_window.class.php on line 129

Leave a Reply

Your email address will not be published. Required fields are marked *