Update DIV Classes with AJAX Json Array Result

I have a Ajax Json Array result made of Divs in DOM. I want to update the existing DOM data with the new Ajax Json Result. The DOM data and the Ajax data both have a id number that can be used to match. I used to have the form within the div, so it was easy to update because all I had to do was use $(this) or $(this)closest. Now I have moved the Ajax Get form to outside the Div $(this) or $(this)closest does not work.

I need a method to relate the data and then apply the data based on the id to id relationship or whatever you can recomend. Thank you. Below is where I have got to so far. The Ajax result update data below it shows the person with id:2 surname as Wright. I want to update the DIV. In a nutshell update each record with its update data. Thank you for any help.

<form  class="updateform"  action="" method="" >    
<input type="hidden" class ="customers"  name="" value="<?php echo $mycustomers; ?>">
<a class="update-button"></a>
</form> 
var Ajaxresultdata = [
 {id:1,name:"Mike",surname:"Rynes"},
 {id:2,name:"James",surname:"Wright"},
 {id:3,name:"Helen",surname:"Bills},
 ];
Div rows are json Array result
<div  class="mycustomers">
<div id="1" class ="name">Mike </div><div>="class="surname">Rynes</div>  
<div id="2">class ="name"> James</div><div>="class="surname">Bond</div> 
<div id="3">class ="name"> Helen</div><div>="class="surname">Bills</div> 
</div>
<script>



    var Ajaxresultdata = [
   {id:1,name:"Mike",surname:"Rynes"},
   {id:2,name:"James",surname:"Bond"},
   {id:3,name:"Helen",surname:"Bills},
   ];

    $.each(ajaxresultdata, function( i, person ) {
    
   if(document.getElementById(person.surname)){

   $("#divid").find('.surname').html(person.surname);
    
    }
     });

</script>

227 thoughts on “Update DIV Classes with AJAX Json Array Result”

  1. Asking questions are truly fastidious thing if you are not understanding something fully, however this piece of writing offers pleasant understanding yet.

    Reply
  2. Wonderful goods from you, man. I’ve take into
    accout your stuff previous to and you’re just extremely magnificent.
    I actually like what you’ve obtained here, certainly like what you are stating and
    the way in which in which you say it. You make it enjoyable
    and you continue to care for to stay it wise. I can’t wait to learn far
    more from you. This is really a great site.

    Reply
  3. Neat blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple adjustements would
    really make my blog stand out. Please let me know where you got
    your design. Thank you

    Reply
  4. You really make it seem really easy with your presentation but I find this topic to be
    really something which I believe I would never understand.
    It sort of feels too complex and extremely broad
    for me. I’m taking a look forward for your next put up, I will attempt to get the hold of it!

    Reply
  5. Good day I am so glad I found your blog page, I really found you by error, while I was searching on Aol for something else, Nonetheless I am here now and would just like to say thanks for a marvelous post and a all
    round exciting blog (I also love the theme/design), I don’t have time
    to browse it all at the moment but I have
    saved it and also included your RSS feeds, so when I have time
    I will be back to read a great deal more, Please
    do keep up the great work. cheap flights http://1704milesapart.tumblr.com/ cheap flights

    Reply
  6. Pingback: cost of viagra
  7. Pingback: herbal viagra
  8. Pingback: 20mg cialis daily
  9. Pingback: cheap cialis
  10. Pingback: generic for viagra
  11. Pingback: liquid cialis
  12. Pingback: otc viagra
  13. Pingback: cialis vs levitra
  14. Pingback: free viagra
  15. Pingback: cialis uk
  16. Pingback: drugs like cialis
  17. Pingback: tadalafil lilly
  18. Pingback: cialis daily use
  19. Pingback: viagra 100mg
  20. Pingback: visual viagra
  21. Pingback: womens viagra
  22. Pingback: viagra vs cialis
  23. Pingback: natural viagra
  24. Pingback: viagra meaning
  25. Pingback: female viagra pill
  26. Pingback: roman viagra
  27. Pingback: fildena
  28. Pingback: women viagra

Leave a Comment