0

Before closing the body tag of my first.php page, I want to load pop.html by javascript. Both are sitting on the root folder of my public_html directory.

By using this code:

<script type="text/javascript"> $( "#modal-layer" ).load( "pop.html" ); </script> 

It works when I access first.php directly:

http://www.example.com/first.php

But since I'm using a pretty URL for this page, such as:

http://www.example.com/pretty/first/

pop.html won't load because of the path.

How can I load it? the weird thing is that I even tried an absolute path:

<script type="text/javascript"> $( "#modal-layer" ).load( "http://www.example.com/pop.html" ); </script> 

But even this didn't work.

Note that I need a universal solution rather than a path form that will go up only one level, as some of my pages have pretty urls that go deeper than one level.

3
  • 1
    Open your developer console, and report the error here... Commented Feb 23, 2016 at 23:55
  • is the pretty url (http://www.example.com/pretty/first/) on the same domain as the original (http://www.example.com/first.php) url? Commented Feb 23, 2016 at 23:56
  • @BillyMoon You are right, actually problem was with a path inside pop.html. Though since I saw [this thread ](stackoverflow.com/questions/2188218/…) I thought maybe my problem was related to that case. Commented Feb 24, 2016 at 0:02

1 Answer 1

2

Best solution is probably an absolute path with no scheme or domain part:

<script type="text/javascript"> $( "#modal-layer" ).load( "/pop.html" ); </script> 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, my problem was actually somewhere else but this is indeed what I should use nonetheless.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.