Javascript jQuery

jQuery Ajax

jQuery("text.learn_more_title").click(function () {
    jQuery.ajax({
        url: 'api_endpoint',
        type: 'POST',
        dataType: 'JSON',
        crossorigin: true,
        data: {
            'customer_id': 'CustomerId',
            'id': 'asset_id'
        },
        crossorigin: true,
        xhrFields: {
            withCredentials: true
        },
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", 'api_token')
        },
        error: function (e) {

        },
        success: function (res) {

            console.log(res);
        },
        complete: function () {

        }
    });
});

 

Leave a Reply

Your email address will not be published. Required fields are marked *