php - Updating a div on success of a ajax/json call -


i have create new album form on page along side delete album form. on sucess of album create automatically update checkbox list in delete album form newly created album details. delete album form gets it's checkbox delete list using php within page. deleting album uses ajax call triggered album delete button, on success return of php delete script checkbox , parent div removed. @ time delete form list updated page has reloaded. there way update delete list without reloading page. posts have looked @ talk append html json message isnt going work, , havent yet seen solution enables refreshing div refreshing page although if there doesnt seem way thats have trigger in album create success return.

jquery add new album

<script type="text/javascript">  $(document).ready(function() {      $("#add_new_catagory").click(function() {      if($("#catagory_name").val()=="" || $("#albumdescription").val()=="")   {      $("#addalbumerror").html("please enter album name , album description");          return false;         }else{       $("#addalbumerror").html('<img src="image/ajax-loader.gif" width="16" height="16" alt=""/>');     var albumname=$("#catagory_name").val();     var albumdescription=$("#albumdescription").val();   $.post("includes/add_albumn_catagory.inc.php",{album_name:albumname,album_description:albumdescription},function(json)   {     if(json.result === "success") {          $("#addalbumerror").html(json.message);          $('#add_category').get(0).reset();        }else{         $("#addalbumerror").html(json.message);     } });     }       });//submit click });//doc ready </script> 

html form delete album woud refresh

<div class="list_album">    <div id="deletealbum_title">delete album</div>  <form action="includes/delete_album.inc.php" id="album_delete">        <p>              <?php              while($row = mysqli_fetch_array($result3)){ ?>            <div id="album_echo_list">              <input name="albumid" type="checkbox" id="addimage" value="<?php echo $row['albumid'];?>">               <?php echo $row['album_name'];?> <?php echo '';?><?php echo $row['albumdescription'];?> <?php echo '<br/>';?>   </div>              <?php } ?>             <br> </p>           </form>   <input name="submit" type="button" id="delete_album_but" style="display:none" title="delete album" value="delete album" form="album_delete"/>      <div id="deletealbumnotice" style="display: block">choose album delete<br>by deleting album pictures , subdirectories in album deleted also!</div>    <div id="deletealbum"></div>  </div> </div> 

i hope managed explain , have posted relevent code

you're expecting response json parsed, never told $.post it's being returned json. add argument:

$.post("includes/add_albumn_catagory.inc.php",{album_name:albumname,album_description:albumdescription},function(json)   {     if(json.result === "success") {          $("#addalbumerror").html(json.message);          $('#add_category').get(0).reset();        }else{         $("#addalbumerror").html(json.message);     } }, "json"); // <<--- response datatype 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -