Displaying AJAX-Fetched Content in a Bootbox Dialog

BootstrapJavascript
2017-08-01 10:40 (8 years ago)
Displaying AJAX-Fetched Content in a Bootbox Dialog

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
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive