Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery post method not executing
    primarykey
    data
    text
    <p>I've never written Ajax before and I am currently trying to code up an infinite scrolling page. When the user scrolls down to the bottom of the page, more items are supposed to load, but right now they aren't loading. Here is my Javascript to detect when they hit the bottom and make the Ajax call:</p> <pre><code>window.onload=function(){ //Find out how many items I have loaded and what filter I am using so I can make the Ajax call var vloaded = &lt;?php echo $i; ?&gt;; var vfilter = "&lt;?php echo $filter ?&gt;"; $(window).on('scroll', function () { if ($(window).height() + $(window).scrollTop() &gt;= $(document).height() - 10) { //I have reached the bottom of the page, now load items alert("loaded is " + vloaded + " and filter is " + vfilter); $.post("/organizer/getMore", { filter: vfilter, loaded: vloaded }, function(responseText) { $("grid").append(responseText); },"html"); //I've loaded the next 30 items, increment my counter for next time vloaded +=30; } }); } </code></pre> <p>The alert is displaying when I hit the bottom, and my variable is incrementing correctly. I'm using Zend Framework, so the URL points to my <code>getMoreAction()</code> function here:</p> <pre><code>public function getmoreAction() { //Used by Ajax to get more items for the infinite scroll //Figure out how I'm filtering items and how many I've already loaded $filter = $_POST['filter']; $loaded = $_POST['loaded']; echo "Filter is ".$filter; echo "Loaded ".$loaded; //Get all the items in the database ordered by filter require_once(APPLICATION_PATH . '/models/ItemArray.php'); $items = ItemArray::getItems($user-&gt;getID(), $filter, $loaded ); //Return items back to Ajax call, converted to html echoItems($items); } </code></pre> <p>I already know the <code>getItems</code> function works, because I'm also using it when the page first loads, and <code>echoItems</code> is just a loop to echo the html for each item, which also works elsewhere. The echos in the action never execute, so I'm assuming there is something wrong with my post call such that I'm never even getting to this action.</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