Created 3 files:

  1. fn.php
  2. script.js
  3. index.php

In fn.php pasted the following code:

<?php if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ if (isset($_REQUEST['catname'])){ $catname = $_REQUEST['catname']; echo select_cat($catname); } } function select_cat($select_cat){ echo $select_cat; } ?> 

In script.js

 function get_category(catname){ var catname = catname; $("#result").html('<img src="loader.gif" />'); $("#result").load("fn.php", { catname: catname }); } 

In index.php

 <div class="r" onclick="get_category('catname');">Click Me</div> <div id="result"></div> 

This whole code works ... jQuery is connected ... Question: how to add the effect that say 1 div appears smoothly, or leaves ... in general, how to add an effect to the code and is it really possible to do it at all.

    2 answers 2

    Choose any of the effects and animations.

    UPD:

     var sidebar_next = $("#sidebar_next"); if(sidebar_next.hasClass('afterAnimation')){ sidebar_next.animate({ marginLeft: "0px" }, 500).removeClass('afterAnimation'); } else { sidebar_next.animate({ marginLeft: "175px" }, 500).addClass('afterAnimation'); } 
    • Thanks, it helped ... now immediately another question if you can: I did this: function get_category (catname) {var catname = catname; $ ("# sidebar_next"). animate ({marginLeft: "175px"}, 500); $ ("# sidebar_next"). load ("fn.php", {catname: catname}); } Now it works for me at the first click to leave ... how can I make it so that on subsequent clicks, the object first calls in and then goes back? - Oll
    • The easiest way is to add a class at the end of the action, and then do a check on it, added its own answer in response - makregistr
     $("#button").toggle( function(){ $("#mydiv").show();}, function(){ $("#mydiv").hide();} ); 

    So, when you click on the button with id = "mydiv", it will appear and disappear mydiv

    • a little something wrong ... it changes the event in turn ... but I need to: 1st click: actions: left the unit - output information in it 2nd click: actions: drive in the unit - leave unit - output the information in it 3- th click: actions: drove a block - left a block - brought information in it 4th click to go to the main: actions: drove a block - Oll
    • Well, write the effects of a chain, here you either made a conclusion from what you were offered here, or it is still too early for you to write this :) - Zowie