I have a website running on Django. When a user clicks a submit button, I need to send data to a server running on a different domain and then display the data returned to the user. I can’t use an Ajax request because of the cross-domain issue. Lots of sources suggest that I should use Javascript to send to my own server which should then send to the external server, but I don’t see how I would implement that.
Share
If you submit the URL that the form eventually needs to go to, you can do the processing on the server side. So say you include a hidden field in the form like so:
Basically you can do something like:
Then, in the view that corresponds to your submit-form URL:
Also, make sure you enable the CSRF-Ajax functionality in Django.
https://docs.djangoproject.com/en/1.4/ref/contrib/csrf/#csrf-ajax
All of the above is just pseudo-code (I just wrote it out here..) but it should give you an idea on how to proceed. Hope this helps 🙂