1

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.

2
  • can you post your jQuery call? Commented Sep 22, 2010 at 17:21
  • This is a webserver misconfiguration, as far as i can see. Which one do you use? Commented Sep 22, 2010 at 17:21

2 Answers 2

4

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!

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

Comments

2

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.

http://en.wikipedia.org/wiki/Same_origin_policy

Comments

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.