0

I have a asp.net website which is supposed to upload files to a handler from a different application / domain. I'm using jQuery Form plugin. When trying to make an example on the same domain (uploading to the same domain) this setup works with success. When trying to upload file with from siteA to siteB I see in firebug that response from handler has been returned (in the Network tab) and is valid, however, the code never enters the 'success' handler, instead giving me such errors in the firebug console:

[jquery.form] Server abort: Error: Permission denied to access property 'document' (Error) log: 
[jquery.form] cannot access response document: Error: Permission denied to access property 'document'
[jquery.form] aborting upload... aborted

In chrome it is:

Unsafe JavaScript attempt to access frame with URL http://domainB/handler.ashx from frame with URL domainA. Domains, protocols and ports must match.

Now, I am aware of the fact that there are some policies about ajax calls between domains, but it seems that jquery form plugin simply tries to access some url that is forbidden. Does anyone have a workaround for it? Any solution please!:)

UPDATE: I ended up hacking jquery.form so it doesn't throw cross-site exception and since I don't need actual result of upload - it works for me!

1 Answer 1

2

Check this and yes, this is a same-origin policy. There are ways to work this around using flash, iframes, jsonp etc but this will require editing a plugin.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, are you suggesting that I should add a page on the domainB and use it as iframe in domainA ?
I'd rather not went that way. Do you need to upload the file only, or some other form stuff as well. If the file only - just use different plugin, which works with cross-domain requests (uploadify does it). If not, use proxying on the same domain and post the file from the handler.ashx code behind code.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.