Note that there are some explanatory texts on larger screens.

plurals
  1. POUse script on div loaded by AJAX
    primarykey
    data
    text
    <p>I need to load external content in a div. I found a code to do that, but my scripts does not work anymore. Someone can help ? I'm novice in this kind of work.</p> <p>Thanks</p> <pre><code>function ajaxFunction(id, url){ var xmlHttp; try {// Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) {// Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange = function(){ if (xmlHttp.readyState == 4) { //Get the response from the server and extract the section that comes in the body section of the second html page avoid inserting the header part of the second page in your first page's element var respText = xmlHttp.responseText.split('&lt;body&gt;'); elem.innerHTML = respText[1].split('&lt;/body&gt;')[0]; } } var elem = document.getElementById(id); if (!elem) { alert('The element with the passed ID doesn\'t exists in your page'); return; } xmlHttp.open("GET", url, true); xmlHttp.send(null); } </code></pre> <p><strong>EDIT - Here is my HTML code. This is were i call my ajax.</strong></p> <pre><code>&lt;div id="right" class="anim"&gt; &lt;div class="exit"&gt; &lt;a class="btnclose"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="portfolio-box" id="git-box"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="container"&gt; &lt;div id="centerContainer" class="col-lg-12"&gt; &lt;div id="grid"&gt; &lt;div class="box" data-category="Branding" data-move="right"&gt; &lt;div class="hide" data-thumbnail="images/portfolio/branding/git.jpg"&gt; &lt;/div&gt; &lt;a type="link" value="Call Project" id="project-link" onclick="ajaxFunction('git-box','portfolio/git.html')"&gt; &lt;div class="thumbnail-caption"&gt; &lt;h3&gt;Groupe&lt;br&gt; intégration&lt;br&gt; Travail&lt;/h3&gt; &lt;h5&gt;Branding&lt;/h5&gt; &lt;/div&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p><strong>EDIT - This is the code that must be activated in the div inserted by AJAX</strong> </p> <pre><code>(function () { var $frame = $('#centered'); var $wrap = $frame.parent(); // Call Sly on frame $frame.sly({ horizontal: 1, itemNav: 'centered', smart: 1, activateOn: 'click', mouseDragging: 1, touchDragging: 1, releaseSwing: 1, startAt: 1, scrollBar: $wrap.find('.scrollbar'), scrollBy: 1, speed: 300, elasticBounds: 1, easing: 'easeOutExpo', dragHandle: 1, dynamicHandle: 1, clickBar: 1, // Buttons prev: $wrap.find('.prev'), next: $wrap.find('.next') }); $(window).resize(function(e) { $frame.sly('reload'); }); }()); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload