0

hi is there a wait to load a full url.?

url= 'http://www.example.com/whatever.php'
$('#selector').load(url);  // this way returns null (empty result)

instead of :

url = 'whatever.php'
$('#selector').load(url); // works fine

Some may think whats the difference i want to use this because im using multiple directories. so i could be on a page like...

example.com/dir/

but the dir folder will not have the whatever.php so anyone has a fix for this that i should always use the full url? thank you.

1
  • I have noticed that the problem is on the "www." if i remove it like so url = 'http://example.com/whatever.php' then it works fine... whats up with that? Commented Jan 5, 2010 at 16:38

2 Answers 2

4

You could always use relative paths

putting / before the path will tell the browser to go the root of the page. For your example you could call /whatever.php.

You can also move up one directory at a time. Lets say you are in a page at http://www.example.com/dir/foo/bar.php and want to access something in the dir folder, you could specify ../inTheDir.php to move up one directory or ../../inTheRoot.php to move up two.

This should work for you, but based on your comment it sounds like you have a problem somewhere else since your www. page doesn't seem to respond correctly.

Sign up to request clarification or add additional context in comments.

1 Comment

thats a clever trick... however this could be a silly setting on the www so ... thank you
-1

No, there isn't.

If http://www.example.com/ takes longer to load than http://example.com/ then it is probably because you have the DNS record for example.com cached but not the record for www.example.com.

Corrected after having realized a typo changed the meaning of the question.:

This is a case of having a mismatch between the host name the page is loaded from and the host name the Ajaxed resource is requested from. i.e. The Same Origin Policy.

Pick a host name to be canonical, use that one in your requests, and redirect (with a 301 status code) from the other so that people don't go to the wrong one by mistake.

2 Comments

http://www.example.com does not return anything at all. where as http://example.com returns what ever its in it. ... does it have disadvantages by using it without the www ?
Ooooh. "Wait" was a typo for "Way"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.