3

this is ultimately frustrating, because it was working on the development site, but after moving it to the live site, it stopped working. :S

$('.menu_btn').click(function(e) {
//rel is used to tell me what html page to load
var url = $(this).attr('rel');
//load the new page into the div
$('#ajax_wrapper').load(url);
});

the even more frustrating thing is, when i hard code the value of url in:

var url = 'http://www.example.com/pages/home.html'

it works without problems.

adding an alert(url) gives me the correct rel address.

2
  • 2
    The link you click what do it look like ?? Commented Jan 10, 2011 at 7:32
  • can we get more code? context of attaching the click event and the html it's affecting... Commented Jan 10, 2011 at 7:33

1 Answer 1

3

Is the domain in the URL the same as the domain of the page? If not, the problem you're having is because

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

via the jQuery docs

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

4 Comments

same domain, different subdomain... would that be the issue?
again... "Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain , or protocol."
alright, it was that... thanks for the help. feel silly that it was something so simple.
@psolms don't be. If a method call refuses to do what you tell it to, it should reasonably throw an exception telling you what the problem is. It shouldn't leave you hanging, wondering why it isn't working.

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.