I have some bootstrap modals that need to load remote content not on click, but when a page loads. To try and accomplish this I have a php variable that is grabbing the right url's dynamically and then putting them in the page as a paragraph tag.
like so
<?=$page = 'dynamic string grabbing from url and other places'?> <p class="valu"><?= $page ?></p> and then I'm setting the modal in the jquery to grab the string and then load the modal with the right content, except that there seems to be issues getting the right page. It's just reloading the page that it is being redirected to.
the jquery I have looks like this
var val = $('valu').text(); $(window).load(function(){ event.preventDefault(); var myModal = $('.largeModal'); var modalBody = myModal.find('.modal-content'); modalBody.load(val); myModal.modal('show'); }); Now if I put the direct string within the modalBody.load it seems to work, although I really need it to be that variable. I thought that maybe it wasn't seeing the text as a string and that was why I was not working, but neither casting the value as a string or concatenating quotes around it worked.
Any help would be much appreciated!
function test(){ var ds1=new Date(); var js=document.getElementsByTagName('a'); var de1=new Date(); console.log(dateDiff(de1,ds1)); var ds2=new Date(); var jq=$('a'); var de2=new Date(); console.log(dateDiff(de2,ds2)); } function dateDiff(de, ds) { return de.getTime() - ds.getTime(); } test();- please execute in your console on this page...and see why you should avoid jQuery, when you can use same thing faster... now all is about speed ... a framework will never beat native stuffs