astralaaron Posted August 17, 2010 Share Posted August 17, 2010 Hi, I am trying to search for information on this but am having trouble finding search words to bring up relevant info...basically what I just noticed... is if I type http://mydomain.com/ instead of http://www.mydomain.com/my AJAX calls do not work. when the www is added, they work fine. Can anyone explain why? and if there's a way to make sure the AJAX fires?EDIT:only tested in firefox btw. Link to comment Share on other sites More sharing options...
astralaaron Posted August 17, 2010 Author Share Posted August 17, 2010 well, guys I included this code to the top of my file:<?php if(!stristr($_SERVER['HTTP_HOST'], 'www')) header('location: http://www.mydomain.com/'); ?>And it redirects and works if they type in the address without the 'www'.But I would still like to understand what is happening if anyone can explain? Link to comment Share on other sites More sharing options...
Ingolme Posted August 17, 2010 Share Posted August 17, 2010 For security reasons, AJAX requests can only be done on the same domain as the page that's making the request. If your page is on www.mydomain.com then a request to domain.com won't work because it's considered a different domain.Besides redirection, you could also use the window.location object to see which domain your script is currently running in and use that one for the request. Link to comment Share on other sites More sharing options...
astralaaron Posted August 24, 2010 Author Share Posted August 24, 2010 Thank you, I get it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.