Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ajax call to load a page on scrolling

var position = $(window).scrollTop();
var bottom = $(document).height() - $(window).height();
Comment

ajax call to load a page on scrolling

CREATE TABLE `posts` (
  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `link` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Comment

ajax call to load a page on scrolling

<?php

$host = "localhost"; /* Host name */
$user = "root"; /* User */
$password = ""; /* Password */
$dbname = "tutorial"; /* Database name */

$con = mysqli_connect($host, $user, $password,$dbname);

// Check connection
if (!$con) {
  die("Connection failed: " . mysqli_connect_error());
}
Comment

ajax call to load a page on scrolling

<?php

// configuration
include 'config.php';

$row = $_POST['row'];
$rowperpage = 3;

// selecting posts
$query = 'SELECT * FROM posts limit '.$row.','.$rowperpage;

$result = mysqli_query($con,$query);

$html = '';

while($row = mysqli_fetch_array($result)){
  $id = $row['id'];
  $title = $row['title'];
  $content = $row['description'];
  $shortcontent = substr($content, 0, 160)."...";
  $link = $row['link'];
  // Creating HTML structure
  $html .= '<div id="post_'.$id.'" class="post">';
  $html .= '<h1>'.$title.'</h1>';
  $html .= '<p>'.$shortcontent.'</p>';
  $html .= '<a href="'.$link.'" target="_blank" class="more">More</a>';
  $html .= '</div>';

}

echo $html;
Comment

ajax call to load a page on scrolling

.container{
 width: 55%;
 margin: 0 auto;
 border: 0px solid black;
 padding: 10px 0px;
}

/* post */
.post{
 width: 97%;
 min-height: 200px;
 padding: 5px;
 border: 1px solid gray;
 margin-bottom: 15px;
}

.post h1{
 letter-spacing: 1px;
 font-weight: normal;
 font-family: sans-serif;
}


.post p{
 letter-spacing: 1px;
 text-overflow: ellipsis;
 line-height: 25px;
}

/* more link */
.more{
 color: blue;
 text-decoration: none;
 letter-spacing: 1px;
 font-size: 16px;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to call function on every keypress in jquery 
Javascript :: simple search filter for table html 
Javascript :: one line if statement javascript 
Javascript :: what hostings can run react js 
Javascript :: js class syntax 
Javascript :: how to check request type in js 
Javascript :: empty object is falsy 
Javascript :: spam system discord.js 
Javascript :: prisma decimal 
Javascript :: create window electron 
Javascript :: js for i in html collection 
Javascript :: how to uninstall nodejs web server 
Javascript :: js regex return null 
Javascript :: how to decode jwt token at frontend 
Javascript :: clear dict javascript 
Javascript :: how to delete a parameter with js 
Javascript :: pwa clear cache 
Javascript :: html form structure 
Javascript :: jQuery - Remove 
Javascript :: js ismobile detected 
Javascript :: map and filter js 
Javascript :: how to add a tilemap in phaser 3 
Javascript :: push method in javascript 
Javascript :: trimend in javascript 
Javascript :: toast js 
Javascript :: uselayouteffect 
Javascript :: create canvas p5 
Javascript :: apexcharts bar onclick index 
Javascript :: nestjs queues 
Javascript :: change form value dynamically angular 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =