using a variable in jquery load() not working
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.htm开发者_JS百科l'
it works without problems.
adding an alert(url)
gives me the correct rel address.
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
精彩评论