Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery append <div> based on the viewport and ajax refresh on browser resize
    primarykey
    data
    text
    <p>Hi a jQuery newbie question. I am trying to add different sidebars based on browser view-port.</p> <p><strong>Here is my script:</strong></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Viewport Test&lt;/title&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function reloadPage(width) { width = parseInt(width); if (width &gt; 1440) { $('#aside').load('widepage.php'); } else if (width &gt;= 1024 &amp;&amp; width &lt;= 1440) { $('#aside').load('narrowpage.php'); } } $(function() { reloadPage($(this).width()); $(window).resize(function() { reloadPage($(this).width()); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;!-- Here I want to append the external php Script --&gt; &lt;div id="content"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>What i need to do is :</strong></p> <ol> <li><p>Ajax load these sidebars while rest of the page continues loading.</p></li> <li><p>I do not want to load them into a div but <strong>APPEND</strong> them before <code>&lt;div id="content"&gt;&lt;/div&gt;</code></p></li> <li><p>I want the php scripts in various files to be appended and not the output.</p></li> <li><p>On browser resize, only the appended part should reload.</p></li> </ol> <p><strong>My Question:</strong></p> <p>Am I doing the right way? If not what is the correct way. Please explain with code illustrations as I am totally new to JavaScript.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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