Test ajax triggers

by justin_barber_arvig

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Type Some text in text box and click out of text box </br>
 <form class="isAjax" action="workshop\something" data-reload="doSomething">
     <input name="keyword" type="text"/>
 </form>
 <div data-name="doSomething">
 </div>

JavaScript

/*
* The following document will be used for basic ajax functionality
* If this file is changed in any way make sure to test existing work
* example: any element with class "isAjax" or "ajax-defer"
*/



    /*
     * Basic loader html
     */
    var loaderBlock = '<div class="text-center ajaxLoader">\n' +
        '                    <div>\n' +
        '                        <span class="fa fa-cog fa-spin" style="color:#3a366b40;"></span>\n' +
        '                        <span class="fa fa-cog fa-spin" style="color:#c0d52f;"></span>\n' +
        '                    </div>\n' +
        '                    <div style="margin-top: -17px;">\n' +
        '                        <span class="fa fa-cog fa-spin-reverse" style="color:#3a366b;"></span>\n' +
        '                    </div>\n' +
        '                </div>';
     /*
      * Basic warning html
      */
    var warningBlock =  '<div>' +
    '                        <div class="text-center">\n' +
    '                            <i class="fas fa-exclamation-triangle text-danger" style="font-size: 3em;"></i>\n' +
    '                        </div>' +
    '                    </div>';

     /*
      * Add message to error icon
      */
    function createErrorIcon(errorMsg){
        var block = $(warningBlock)
        block.find('div').append('<div>' + errorMsg + '</div>');
        return block.html();
    }

    /*
     * Make the ajax call
     * action = String action of form or data-action of div
     * target = Object of element
     * params = Array of parameters
     * type = String 'GET', 'POST' etc.
     */
    function makeAjaxCall(action, target, params, type) {
    console.log('ajaxCalled');
    target.html('WE DID SOMETHING!!!' + params);
      /* $.ajax({
            url:action,
            data:params,
            type:type,
            beforeSend: function( xhr ) {
                target.html(loaderBlock);
            },
            success: function (data) {
               ...