Forum Moderators: open
// external CSS
#classifiedList { margin-left: 180px }
// PHP
$frag = 'blah blah blah'; // the link of the page we're on
// JavaScript
// usage: onClick="loadFragment('list')"
// or onClick="loadFragment('grid')"
function loadFragment(viewstyle) {
var url = '$frag' + '&viewstyle=' + viewstyle;
$('#classifiedList').load(url + ' #classifiedList');
} $('#classifiedList').load(url + ' #classifiedList', function() {
$('#classifiedList').css('margin-left', 0);
}); <div class="sized">
#classifiedList
</div> $('#classifiedList').load(url + ' #classifiedList', function() { I do not have an answer to your question as asked, and don't know enough about how this script "fits" in the overall page to know whether it would be silly to ask: can the list/views be contained in a sized div that is not part of the content being loaded once, twice or more? I mean if "{ margin-left: 180px }" is not assigned to "#classifiedList" but to a container for "#classifiedList" would that help?
Do not proceed with using the "#" hash method. This is going make your pages uncrawlable by Google. Each additional section of your page should have is its own distinct URL and if possible when a user types the URL the browser should take the user to that page. You can use pushState() to update the URL as new content is loaded.
There is one other warning to share (this one I have mentioned before) avoid using document.write() and any commands that use it under the hood such as $().html();. This may in fact be the cause of your apparent bug.
The classifieds page currently uses Page 1 as default, then if you go to classifieds/?s=20 it goes to Page 2 (starting at the 20th record). So s=40 is Page 3, s=60 is Page 4, and so on.
But which part of my script is using it? Is it part of the root to $.load?
I'm not sure how your page is working exactly. $.load() simply executes a script after the page loads. So it would really depend on the script that is being executed if any. It is not clear to me from what you shared, is it a php script?
Also in researching my answer I noticed that $.load() is deprecated as jQuery1.8.
jQuery uses the browser's .innerHTML property to parse the retrieved document and insert it into the current document.
$( "#b" ).load( "article.html #target" );. $('#classifiedList').load(url + ' #classifiedList', function() {
$('#classifiedList').css('margin-left', 0);
});