biasedbit
biasedbit

Reputation: 2870

Cross-(sub)domain AJAX POST request (with file/large body)

I need a script to perform a POST request to a different sub-domain than the one the page loads from, e.g. load data from domain.com and perform the AJAX POST to post.domain.com.

I've read about some alternatives that work for mainly for GET or POST with simple form data, but in this case I'll be posting a file (can be quite large).

I control the server, and both the page and the target are under the same domain. Is there any way to do this with JS/Iframes or do I have to resort to Flash/Flex?

As a side question, does mod_proxy for apache redirect a POST when the HTTP request is fully read (at apache) or it starts redirecting traffic (like a TCP tunnel) as soon as the headers are read?

Upvotes: 2

Views: 2968

Answers (2)

0x6A75616E
0x6A75616E

Reputation: 4716

For requesting data from another subdomain you could look at JSONP

For posting files you can definitely use iframes.

This is a good tutorial: http://www.openjs.com/articles/ajax/ajax_file_upload/

Upvotes: 1

Related Questions