Title: Append data clear after second click
Last modified: August 19, 2016

---

# Append data clear after second click

 *  Resolved [vjn_23](https://wordpress.org/support/users/vjn_23/)
 * (@vjn_23)
 * [15 years ago](https://wordpress.org/support/topic/append-data-clear-after-second-click/)
 * Hi,
 * I am using WordPress 3.1.2. This time i have one doubt, same time using wordpress
   JSON API plugin in my website. i try this code in sample.js file
 * function displayBrandDesign(){
    $(“#brand-design”).show(); $.ajax({ type: “GET”,//
   url: “api/get_recent_posts/?custom_fields=gallery_thumb,gallery_zoom&slug=’brand-
   design'”, url: “api/get_category_posts/?custom_fields=gallery_thumb,gallery_zoom&
   slug=’brand-design'”, dataType: “json”, success: function(data){ $.each(data.
   posts, function(index, value) { c.append(‘<img src=”‘+value.custom_fields.gallery_thumb
   +'”/>’); }); } }); }
 * in html file :-
    using like this [Brand Design](https://wordpress.org/support/topic/append-data-clear-after-second-click/?output_format=md#)
   <div id=”brand-design”></div>
 * what my doubt is, when i click the Brand Design button. First time its showing
   properly, but second time clicking the Brand design link its appened and continuously
   showing same custom field image.
 * When i second click the link, same time clear the data in #brand-design div items,
   and showing without append function. how can i use the jquery code.
 * thank U
    vjn_23

Viewing 1 replies (of 1 total)

 *  Thread Starter [vjn_23](https://wordpress.org/support/users/vjn_23/)
 * (@vjn_23)
 * [15 years ago](https://wordpress.org/support/topic/append-data-clear-after-second-click/#post-2071336)
 * thank U,
 * I solved the problem. Replace the code like this :-
 * success: function(data){
    $(“#brand-design img”).remove(”); $.each(data.posts,
   function(index, value) { $(“#brand-design”).append(‘<img src=”‘+value.custom_fields.
   gallery_thumb+'”/>’); }); }

Viewing 1 replies (of 1 total)

The topic ‘Append data clear after second click’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [vjn_23](https://wordpress.org/support/users/vjn_23/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/append-data-clear-after-second-click/#post-2071336)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
