2

I have a user using my plugin with the following wp setup

WordPress Address (URL)
http://server1.theirhost.com/~acct/somewebsite.com/wordpress

Site Address (URL)
http://www.somewebsite.com

I am using admin_url( 'admin-ajax.php' ) to pull the ajax url, which returns

http://server1.theirhost.com/~acct/somewebsite.com/wordpress/wp-admin/admin-ajax.php

When doing ajax requests from a page on http://www.somewebsite.com, it looks like the "same origin policy" is in effect and the requests fail. Any suggestions on how to fix this issue?

1
  • So there is no wordpress on the domain http://somewebsite.com ? Do a server to server request to avoid same origin policy.
    – Sisir
    Commented Mar 19, 2012 at 16:57

1 Answer 1

4

Depending on how you're mapping somewebsite.com, you can probably just define ajaxurl differently:

var ajaxurl = 'http://www.somewebsite.com/admin-ajax.php';

If you need something more generalizable, you could filter admin_url, sniff out whether it's asking for admin-ajax.php, and if so, then rewrite it using home_url() or something like that.

Getting cross-domain ajax to work is possible (with a proxy approach, for instance) but it's best to avoid it if at all possible.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.