In some parts of my web application I've ajax login mechanism, after successful login I'm updating topbar using following code instead of refreshing the page.
$("#top-bar").load($(location).attr('href'));
Above line of code updating topbar without any issue, but in some pages I've openlayers maps there, page structure is totally destructing due to above line. Because I'm using jQuery tabs on same page.
After searching I came to know that some special characters in the script may cause these type of issues. So its difficult to find which line of code is causing this issue, finally I'm using below line to update the topbar.
$("#top-bar").load($(location).attr('href')+' #top-bar');
This line of code is working without any issues, as a developer I want to know what is difference between above two calls ?
Edit
There is even issue with my first call, I was not observed the destructed part of the page. After reading answers I've clearly observed the page. Anyhow second call is the perfect one for me. Sorry for giving trouble by asking this type question, thanks for everyone who contributing for this question.
The first example is loading the entire HTML contents of the external page in the
hrefand inserting everything:$("#top-bar").load($(location).attr('href'));The second example is loading the entire HTML contents of
href, but only inserting the#top-barfrom that page rather than the entire document:$("#top-bar").load($(location).attr('href')+' #top-bar');.load() API docs