Showing posts with label ajax call. Show all posts
Showing posts with label ajax call. Show all posts

Thursday, 25 April 2013

Get Facebook Comments details by ajax request.

      var url = "http://getpaidtomeme.com/image.aspx?imagenum=15195";
      $.ajax({
            url: "https://graph.facebook.com/comments/?ids="+url+"",
            dataType: "jsonp",
            success: function (data) {
                 alert(JSON.stringify(data));
            },
            error: function (data) {
                consol.log(data);
            }
     });

Just change url here.

Live Demo



Get tweet and user detail from twitter API using JQuery

var username = "ankushjain99";
$.ajax({
            url: "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name="+username+"&count=20",
            dataType: "jsonp",
            success: function (data) {
                 alert(JSON.stringify(data));
            },
            error: function (data) {
                consol.log(data);
            }
});

Just Change username

Live Demo



Use Google Currency Converter API in JQuery

        function buildQuery(amount, from, to) {
            var str = "http://www.google.com/ig/calculator?hl=en&q=" + amount + "" + from + "%3D%3F" + to + "";
            return "select * from json where url ='" + str + "' ";
        }

        $.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
            data: {
                q: buildQuery("100","KWD","INR"),
                format: "json"
            },
            dataType: "jsonp",
            success: function (data) {
                alert(data.query.results.json.lhs + "=" + data.query.results.json.rhs);
            },
            error: function (data) {
                consol.log(data);
            }
      });
Just change buildQuery("100","KWD","INR") parameters.

Live Demo



Saturday, 20 April 2013

Get number of likes on page from facebook by ajax request.

You can get number of likes of page from facebook by ajax request

Here is example
$.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "http://graph.facebook.com/https://www.facebook.com/Cyprusjetset",
            dataType: "json",
            success: function (data) {
                alert(data.likes);
            },
            error: function (result) {
                alert("Sorry no data found.");
            }
});




Getting cross domain JSON Data by ajax request

Their is two way to get data from other domain.

1. By using YQL Yahoo Service. Here is example :-

function buildQuery(term) {
    return "select * from json where url = 'http://airportcode.riobard.com/search?fmt=JSON&q=" + term + "'";
}

$.ajax({
        url: 'http://query.yahooapis.com/v1/public/yql',
        data: {
            q: buildQuery(YourURL),
            format: "json"
        },
        dataType: "jsonp",
        success: function(data) {
            alert(JSON.stringify(data));
        },
        error: function (data) {
            consol.log(data);
        }
});


2. By using $.getJSON Here is example-


$.getJSON("http://kalpa.freeoda.com/news/news_feed.php?callback=?", null, function (data) {
            alert(JSON.stringify(data));
});