jquery - Ajax success callback- DOM not updating -
i running $.ajax
function. data want returned in json format, , able parse , properties want. then, when try change dom, isn't changing. console.log()
statements show things changing, when view source of page original element still there.
code:
$.ajax({ success: function (jsonimagestring) { if (jsonimagestring.length > 0) { var embeddedimages = $.parsejson(jsonimagestring); $.each(embeddedimages, function () { var currpin = this.pin; var currurl = this.url; var currtitle = this.title; //statement displays correct pin console.log(currpin); //statement shows correct original html console.log($("a[href='" + currpin + "']").html()); //nothing changes- viewing source of page shows original elements $("a[href='" + currpin + "']") .addclass("displaylink") .html("<img src='" + currurl + "' alt='" + currtitle + "' />"); //shows if had changed... console.log($("a[href='" + currpin + "']")[0].outerhtml); }); } } });
when view source of page
how viewing source?
presumably you're using "view source" menu option in browser? browser's "view source" menu option shows original source fetched server. see updated changes want use dom explorer, part of browser's debugging tools.
the dom being updated, it's original source isn't.
Comments
Post a Comment