Fix infinite content ajax call parameters
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 3 Nov 2020 01:07:26 +0000 (20:07 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 3 Nov 2020 01:07:26 +0000 (20:07 -0500)
- Ajax request could end up in a 404 if the page URL didn't have at least a query string parameter

view/js/main.js

index 2e665d1..175f68c 100644 (file)
@@ -893,16 +893,29 @@ function loadScrollContent() {
 
        // get the raw content from the next page and insert this content
        // right before "#conversation-end"
-       $.get(infinite_scroll.reload_uri + '&mode=raw&last_received=' + received + '&last_commented=' + commented + '&last_created=' + created + '&last_uriid=' + uriid, function(data) {
+       $.get({
+               url: infinite_scroll.reload_uri,
+               data: {
+                       'mode'          : 'raw',
+                       'last_received' : received,
+                       'last_commented': commented,
+                       'last_created'  : created,
+                       'last_uriid'    : uriid
+               }
+       })
+       .done(function(data) {
                $("#scroll-loader").hide();
                if ($(data).length > 0) {
                        $(data).insertBefore('#conversation-end');
-                       lockLoadContent = false;
                } else {
                        $("#scroll-end").fadeIn('normal');
                }
 
                document.dispatchEvent(new Event('postprocess_liveupdate'));
+       })
+       .always(function () {
+               $("#scroll-loader").hide();
+               lockLoadContent = false;
        });
 }