javascript - Update div with jQuery ajax response html Not Posting Back to Page -
i've been struggling few days , can't figure out why won't work. need update link on page new file. post request , new file show in google chrome development network, actual page won't update. have checked other posts , can't figure out. understanding code should updating div "mapdata" new link, image, etc. page response in development window has right html page , need take div portion it, alter in html page displayed, , have page update. should simple!
function updatepiefact(){ var scenario = $("#scenario").val(); var year_run = $("#year_run").val(); var acttype = $("input:radio[name=acttype]:checked").val(); var zntype = $("input:radio[name=zntype]:checked").val(); var info = {'piefact': piefact, 'csrfmiddlewaretoken':'f89lua2qmat7oz6057pvcahr3eusstyi', 'scenario':scenario, 'year_run':year_run, 'acttype':acttype, 'zntype':zntype}; $.post(url, data, function(data){ var result = $('<div />').append(data).find('#mapdata').html(); $("#mapdata").html(result); }); } var piefact = 1; $(document).ready(function(){ $('#bttnminus').click(function(){ piefact*=0.75; updatepiefact(); }); $('#bttnplus').click(function(){ piefact*=1.25; updatepiefact(); }); });
did mean this?
$.post(url, data, function(result){ var mapdatahtml = $(result).find("#mapdata").html(); $("#mapdata").html(mapdatahtml); }); if buttons within of mapdata element, bindings removed when reload html. you'll want utilize jquery.on instead of click.
$(document).on('click', '#bttnminus', function(){ piefact*=0.75; updatepiefact(); }); javascript jquery html ajax http-post
No comments:
Post a Comment