Ok a have an script for submiting input data. There is an url of my site going like this : http://www.<!mywebsite!>.com
. This ajax request works perfectly when user is viewing my iste on http://www.<!mywebsite!>.com
, but when he visits my site without www. e.g. http://<!mywebsite!>.com
than the request doesn't works. I was wondering is there any way to handle this dynamically. Don't suggest redirection because that is not a good solution, cuz of google bots and website ranking. Thanks. Correct me if i said something wrong.
views:
60answers:
2
+2
A:
This smells a bit like a same-origin policy issue.
In your ajax call, are you fully qualifying the destination URL?
i.e., do you have something like:
$.ajax({ url: 'http://www.whatever.com/script.php', ... });
If you do, change it to use a relative url like so:
$.ajax({ url: '/script.php', ... });
And let me (us) know if that helps.
Good luck!
mkoistinen
2010-09-22 17:25:30
A:
You should use relative path in your query. The problem with using absolute path with the server address is that with Ajax you can't do request to an other domain than the one you are on currently on.
You need to know that http://www.example.com/ is not on the same domain as http://example.com/
See this for more detail on the same origin policy that applies to Ajax request.
HoLyVieR
2010-09-22 17:27:09