tags:

views:

44

answers:

1

Hi All!

I m actually put of my min with this code ....

$.ajax({
                'url'               : site_root + '/ajax.php',
                'type'          : 'POST',
                'data'          : 'function=check_user_login_name&user_login=' + user_login,
                beforeSend  : function()
                {
                    $('#check_result_span').html('Checking ...');
                },
                success         : function(data)
                {
                    if(data != 1)
                    {
                        $('#check_result_span').addClass('green').html('Available!');
                    }
                    else
                    {
                        $('#check_result_span').addClass('red').html('Already taken!');
                    }
                }
            });

This works fine on local machine, but not on server ...

the server page link is http://onlyfreelancer.com/signup.php

Please click on the "Check availability" link, nothing happens on server but on local it shows if the user login name is still available or not

Any help plz?

+1  A: 

When that link is clicked, the resulting request is for:

http://www.onlyfreelancer.com/ajax.php

but (at least in my Safari debugger), the origin is seen as

http://onlyfreelancer.com

Perhaps this is a "same origin policy" issue. Can you set up your code to request ajax.php from onlyfreelancer.com (no www)?

Ken Redler
actually http://www.onlyfreelancer.com/ajax.php is the link where the post is being made. i have a var site_root which holds "http://www.onlyfreelancer.com"
anjan
Yes -- so `site_root` = `http://www.onlyfreelancer.com`, thus your ajax call URL is `http://www.onlyfreelancer.com/ajax.php`. But you're loading it from the page `http://onlyfreelancer.com/signup.php`. No www. The same origin policy wants to see the same URL in the calling page and the page requested via ajax.
Ken Redler
Yep! Thats it. Sorry, Ken i had a misconception about the same origin policy. i thought ajax calls just need to be done to same domain and didn't count for subdomains. Many thanks :)
anjan