Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //declaration de JQUERY en javascript, pas le choix
- const scriptJquery = document.createElement("script");
- scriptJquery.setAttribute("src","https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js");
- document.head.appendChild(scriptJquery);
- var modalContent;
- //une fois le Jquery chargé, on ajoute le reste en JQUERY
- scriptJquery.onload = function() {
- //Ajouter bootstrap js et css
- $('head').append('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" type="text/css" />');
- $('head').append('<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" />');
- //insertion des éléments
- $('body').append('<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">Launch demo modal</button>');
- $.get(
- 'http://modal.local/modal1.html', // Le fichier cible côté serveur.
- getresponse, // Nous renseignons uniquement le nom de la fonction de retour.
- 'html' // Format des données reçues.
- );
- function getresponse(data){
- modalContent = data;// Du code pour gérer le retour de l'appel AJAX.
- $('body').append(modalContent);
- }
- // $(document).ready(function() { setTimeout(openModal,1000) });
- };
- function openModal(){
- $('#exampleModalCenter').modal('toggle')
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement