Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript include_once- javascript php calling same file duplicating content
    primarykey
    data
    text
    <p>I am using ajax to load a php script that shows content based on screen resolution. The script works great, but the url that ajax calls is also called later in the script-- it holds all of the processing information. So, the result is all content is loaded via jquery and then duplicated with php. Example:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $.ajax({ url: 'functions/maxresults.php', type: 'GET', data: {h: screen.height, w: screen.width} }).done(function ( data ) { alert("I am working!"); document.getElementById("container").innerHTML=data; }); }); &lt;/script&gt; </code></pre> <p><em><strong>And further down</em></strong></p> <pre><code>&lt;?php include_once("functions/maxresults.php"); ?&gt; </code></pre> <hr> <pre><code>&lt;?php require_once("databasefunctions.php"); ?&gt; &lt;div id="container"&gt; &lt;div id="movieinfo"&gt; &lt;?php include("sidebar.php");?&gt; &lt;?php // get the function include_once ('function.php'); if($_GET['page']) $page = $_GET['page']; else $page = 0; $maxresults = -1; if(($_GET['w']) &amp;&amp; ($_GET['h'])) { $w = $_GET['w']; $h = $_GET['h']; } if ($w == 1920) { $maxresults = 24; } else if ($w == 1600) { $maxresults = 21; } else if ($w == 1440){ $maxresults = 14; } else if ($w == 1366) { $maxresults = 21; } else if ($w == 1024) { $maxresults = 8; } else $maxresults = 6; echo $maxresults; $currentpage = $page; $page = $page*$maxresults; $numpages = QuickQuery("SELECT COUNT(id) FROM movies WHERE visible=1"); $numpages = mysql_result($numpages, 0); $numpages = $numpages/$maxresults-1; $result = GetMoviesByRangeID($page, $maxresults);//Show &lt;maxresults&gt; pages at a time DisplayResults($result); ?&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I cannot remove the php include or the script won't work at all. Would creating an include_once in the jquery work and if so, how do I code it? </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