post/static/post/main.js
/**
 * Sends an AJAX request and fixes the response to the top and is faded after sometime.
 * @param {string} link - Link where the AJAX request is to be sent
 * @param {object} args - The args object may contain the atttributes {type, data, responseType}
 * If not passed their default value will be :
 * type:POST
 * data:''
 * responseType:json
 */
Sends an AJAX request and fixes the response to the top and is faded after sometime.
@param {string} link - Link where the AJAX request is to be sent
@param {object} args - The args object may contain the atttributes {type, data, responseType}
If not passed their default value will be :
type:POST
data:''
responseType:json
Sends an AJAX request and fixes the response to the top and is faded after sometime . @param { string } link - Link where the AJAX request is to be sent @param { object } args - The args object may contain the atttributes { type data responseType } If not passed their default value will be : type : POST data : ' ' responseType : json
function sendAjax(link, args) {
    let type, data, responseType;
    if (typeof args.type === "undefined") {
        type = 'POST';
    } else {
        type = args.type;
    }
    if (typeof args.data === "undefined") {
        data = '';
    } else {
        data = args.data;
    }
    if (typeof args.responseType === "undefined") {
        responseType = 'json';
    } else {
        responseType = args.responseType;
    }
    jq.ajax({
        type: type,
        headers: { 'X-CSRFToken': window.CSRF_TOKEN },
        url: link,
        contentType: 'application/' + responseType,
        data: JSON.stringify({ 'data': data }),
        error: function (jqXhr, textStatus, errorMessage) {
        },
        success: function (data, status, xhr) {
        },
        complete: function (data) {
            try {
                const state = data.responseJSON['status'];
                if (state == -1) {
                    top.location.href = '/login';
                }
                const msg = data.responseJSON['message'];
                createResponse(state, msg);
            } catch (e) {
                console.log(e);
            }
        },
    });
}
function sendAjax ( link , args ) { let type , data , responseType ; if ( typeof args . type === "undefined" ) { type = 'POST' ; } else { type = args . type ; } if ( typeof args . data === "undefined" ) { data = '' ; } else { data = args . data ; } if ( typeof args . responseType === "undefined" ) { responseType = 'json' ; } else { responseType = args . responseType ; } jq . ajax ( { type : type , headers : { 'X-CSRFToken' : window . CSRF_TOKEN } , url : link , contentType : 'application/' + responseType , data : JSON . stringify ( { 'data' : data } ) , error : function ( jqXhr , textStatus , errorMessage ) { } , success : function ( data , status , xhr ) { } , complete : function ( data ) { try { const state = data . responseJSON [ 'status' ] ; if ( state == - 1 ) { top . location . href = '/login' ; } const msg = data . responseJSON [ 'message' ] ; createResponse ( state , msg ) ; } catch ( e ) { console . log ( e ) ; } } , } ) ; }
Sends an AJAX request and fixes the response to the top and is faded after sometime.
Sends an AJAX request and fixes the response to the top and is faded after sometime .
// const responseType = 'application/ // console.log(type, data, responseType, link); // dataType: 'json', // console.log('Error Message:' + errorMessage); // console.log('status:' + status + ', data:' + data); // return data; // console.log(data.responseJSON['message']); // if (data.responseJSON['status'] === 0) { //     const state = 'success'; // } else { //     const state = 'warning'; // } // console.log(data); // console.log(e);