Displaying AJAX-Fetched Content in a Bootbox Dialog

Bootstrap Javascript
2017-08-01 19:40 (7 years ago) ytyng

Here is an example code showing how to display the content retrieved via AJAX within a Bootbox dialog.

Asynchronous (Recommended)

        var bb = bootbox.dialog({
            message: 'Loading...',
            onEscape: true,
            backdrop: true
        });
        var bbBody = bb.find('.bootbox-body');
        $.ajax({
            url: <URL>,
            success: function (data) {
                bbBody.html(data);
            }
        });

Render after waiting for the response (Feels slower)

        $.ajax({
            url: <URL>,
            success: function (data) {
                bootbox.dialog({
                    message: data,
                    onEscape: true,
                    backdrop: true
                });
            }
        });
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011