Use JQuery to Write Data to a Variable

Saturday, April 25, 2020

Needed a way to put data pulled from my API (via Django REST Framework) into a variable for graphing.

jQuery.extend({
    getValues: function(url) {
        var result = null;
        $.ajax({
            url: url,
            method: 'GET',
            async: false,
            success: function (data) {
                result = data;
            }
        });
        return result;
    }
});

Using this I can make a simple call in my scripts and pull back the data I need (in this case for generating graphs using Plot.ly)

var something = $.getValues('/api/something')
javascriptjquerydatadjangodjango-rest-framework

CentOS 8 Software RAID Monitoring

Quick API Auth for Flask