Difference between revisions of "MediaWiki:Common.js"

From SaWikiLeaks
Jump to: navigation, search
(Created page with "Any JavaScript here will be loaded for all users on every page load.: $(function () { $('#lunch-random').html('a'); }());")
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
+
    $(function () {
 
+
        $.ajax({
$(function () {
+
            type: "GET",
  $('#lunch-random').html('a');
+
            url: 'http://sawikileaks.org/extra/lunchalgo.php',
}());
+
            dataType: 'json',
 +
            success: function(jsondata){
 +
                console.log(jsondata.choices);
 +
                $('#lunch-choices').html(jsondata.choices);
 +
            }
 +
        });
 +
        $('#btn-random').click(function() {
 +
            $.ajax({
 +
                type: "GET",
 +
                url: 'http://sawikileaks.org/extra/lunchalgo.php',
 +
                dataType: 'json',
 +
                success: function(jsondata){
 +
                    $('#lunch-random').html(jsondata.percentages + '<br/>' + jsondata.choice);
 +
                }
 +
            });
 +
        });
 +
    }());

Latest revision as of 13:33, 9 May 2017

    $(function () {
        $.ajax({
            type: "GET",
            url: 'http://sawikileaks.org/extra/lunchalgo.php',
            dataType: 'json',
            success: function(jsondata){
                console.log(jsondata.choices);
                $('#lunch-choices').html(jsondata.choices);
            }
        });
        $('#btn-random').click(function() {
            $.ajax({
                type: "GET",
                url: 'http://sawikileaks.org/extra/lunchalgo.php',
                dataType: 'json',
                success: function(jsondata){
                    $('#lunch-random').html(jsondata.percentages + '<br/>' + jsondata.choice);
                }
            });
        });
    }());