I was having a seemingly intermittent problem but I was eventually able to filter it down to the following.
I use “this.href+‘#sections’” in the context of jQuery .load command. when it works, it will fetch #sections part of the target page and do Ajax load on a displayed page. Sometimes this does not work.
Looking at the Chrome console, I saw a page http://mysite.com was requesting http://www.mysite.com/target.html. Since the browser considered this as a cross site reference, it refused to load the content. Obviously, when a page displayed is http://www.mysite.com, everything works.
So my question is why ‘this.href’ returns ‘www.mysite.com’ instead of ‘mysite.com’ even when a displayed page is without “www” prefix?
I modified the .htaccess file to redirect the www-less site request to www site and now the script always works, but this feels like a kludge.
Is this the way ‘this.href’ supposed to work or am I doing something wrong? Any advice is greatly appreciated.