Update multiple areas with jQuery.load() -


jquery allows update single part of page if has id:

$('#mydiv').load('http://my/url/#mydiv'); 

i need update several parts of page (around form). realise could:

  • call load 1 time per region want update, crazy-inefficient.
  • restructure how i'm doing things, detach original form, .load(...) whole page , reattach old form... has habit of messing around focus states.

i guess i'm after way download page (as jquery object) , cross-update particular sections. i'm assuming that's how existing .load() code works. how that?

one solution use $.get:

$.get('http://my/url/', function(response) {     var $page = $(response);      $("#mydiv1").replacewith($page.find("#mydiv1"));     $("#mydiv2").replacewith($page.find("#mydiv2")); }); 

one important thing note jquery remove elements <html>, <body> or <header>, if element direct descendant of 1 of those, use .filter find instead.


Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -