jquery load function not working for .html file that's not in same path

I am using the following jquery code to load a menu on my site.

this is in the header
<script>$(function(){$("#includedContent").load("vert-menu.html");});</script>

Open in new window


this is in the body
<div id="includedContent"></div>

Open in new window


It works fine when "vert-menu.html" is in the same folder as the .html file, but I'm unable to get it to work using relative paths (../vert-menu.html), or by providing the full URL to the file on my site.

Is this not a supported function of jquery or am I missing something?
bobjones1208Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey Dake Senior Director of TechnologyCommented:
The full url should work. Is the url on the exact same domain as your site.   The Ajax requests are subject to same-origin policy. http://en.m.wikipedia.org/wiki/Same_origin_policy

Only thing I can think of on why the full url path would not work.
0
RobOwner (Aidellio)Commented:
Relative URLs should also work but they will be relative to the url

Eg
Say the html template is located
http://www.yoursite.com/mysite/views/vert-menu.html

And your js is at:
http://www.yoursite.com/mysite/js/main.js

And for arguments sake, your index.html
http://www.yoursite.com/mysite/index.html

Then your main.js would look like this:
<script>$(function(){$("#includedContent").load("views/vert-menu.html");});</script>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bobjones1208Author Commented:
This worked.  I had it in the root of my site, so I just created a new subfolder and l linked it how you have above.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.