tags:

views:

25

answers:

2

I'm trying to add nodes to my drupal site, from a campaignsite using AJAX request.
I have set up a menu_callback item in my hook_menu, that checks if any $_POSTs are coming in, and it works if i make a form that has the action='http://mysite.com/menucallback/url', but i get nothing in response if i make the same request with ajax.

I have access arguments set to 'access content'.

If anyone knows what might be the problem, that would be very helpful.
Thank you.

/Anders

A: 

Are the two sites on same domain?

You cannot easily make AJAX requests to urls with a different domain due to the browsers' same origin policy

There are some workarounds, but it makes things a bit more complex and limited.

googletorp
Thank you for the answer. It turns out it's on the same domain, but when we tested it we had to test it from different domains. Just curious though, do you know of any good workarounds? Thank you again./Anders
andersandersson666
@andersandersson666 look up JSONP, which is mainly used for getting JSON.
googletorp
A: 

You could use your form POSTs to fire a service utilizing the Services module. That could be a way.

Kevin