chasethemetal Posted November 3, 2011 Share Posted November 3, 2011 Hey all. I'm trying to the load the contents of a page into another page via this method. $(document).ready(function(){$("#page").load('http://www.site.com/site.php');}); <div id="page"></div> And I've noticed I'm getting no Response Headers. Also Safari says "cancelled opening page" in the bottom. Any thoughts... Nothing load,and the page is on the same site. Link to comment Share on other sites More sharing options...
Ingolme Posted November 3, 2011 Share Posted November 3, 2011 AJAX requests only allow you to load pages from your own domain. You can use PHP or another server-side language to load content from another domain. Link to comment Share on other sites More sharing options...
chasethemetal Posted November 3, 2011 Author Share Posted November 3, 2011 No thats the thing. It is on the same domain... The page exists on mysite.com/main.php And the page it's trying to get is at mysite.com/folder/folder/page.php. And I've got other pages that use this method... I'm just not sure why it isn't working? Link to comment Share on other sites More sharing options...
chasethemetal Posted November 3, 2011 Author Share Posted November 3, 2011 I got it to work... but not all the way... Basically the path needed to be ('folder/folder/page.php') I took out the whole http://www.mysite.com/.... But now I noticed the JavaScript in the page.php is not being executed.... It loads all html and css, but no client side scripts... I am trying to include pages on a page using jquery instead of targeting iframes. Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2011 Share Posted November 3, 2011 it would be helpful to either show us the code or post a live link, detailing where specifically the problem is occurring. Link to comment Share on other sites More sharing options...
Ingolme Posted November 3, 2011 Share Posted November 3, 2011 It's always a problem trying to execute Javascript from pages loaded with AJAX, because there are dependencies and redundancies involved. I think you should use a server-side language to include page content instead of Javascript. Because if a user has Javascript disabled, they won't be able to get to other pages of your site. Also, when you're including the content of a whole page, you're adding useless <html>, <head> and <body> tags, it's a big mess. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.