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.
You will always receive the same domain from that, it will only differ if it's being retrieved from a different location.
If you would like clarification o this, please provide a test version of the code that you had a bad experience on, so that additional testing by us can help to narrow down the scope of things to the actual cause of the problem.