php - AJAX Show/hide content -


before complains ive tried google there isnt straight forward answer or tutorial of sort..

basically ive got articles paragraph seen *read more" link using javascript shows more content, although slow down website rest of article there hidden.

so question how set ajax/php bring in content instead? know how set database on mysql , right in guessing need type out article in mysql when storing in there? sorry if im saying confusing im confused myself... if explain absolute beginner great google isn't friend after hours of searching.

readmore pic

think ive been misunderstood. above screenshot ive achieved im wanting instead of hiding content displaying on-click have being called in using ajax, database , php

  1. add "previewcutoffindex" or similar articles table.
  2. on page load, display article html / content cutoff index.
  3. for "read more" button, put article identifier attribute
  4. add click handler makes ajax call, load rest of article

markup ("data-article-id" comes php on page load):

<div>     <?php echo $mysqlresult["articlecontent"]; ?> </div> <a id="morebutton" data-article-id="<?php echo $articleid; ?>" href='#'>read more</div> <div id="morecontent"></div> 

javascript (assume you're going use jquery):

$("#morebutton").on("click", function(e) {     e.preventdefault();     var articleid = $(this).attr("data-article-id");      // load article "morecontent" div     $("#morecontent").load("content.php?articleid=" + articleid); }); 

then php content.php should return text (or more markup) remainder of article, based on $_get("articleid").


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -