Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xhr.upload is undefined #46

Closed
terjeto opened this issue Jan 20, 2012 · 8 comments
Closed

xhr.upload is undefined #46

terjeto opened this issue Jan 20, 2012 · 8 comments

Comments

@terjeto
Copy link

terjeto commented Jan 20, 2012

I'm currently developing a file-upload javascript module, and I think that dajaxice somehow is messing things up.

In a fresh console on firefox/chrome i can write:
new XMLHttpRequest().upload ? true :false

which will respond with "true" in the console (requires modern browser)

If i do the same in my django project with dajaxice, I get false

I'm suspecting that the xmlHttpRequst object get's manipulated within dajaxice.

This is unfortunate as xhr.upload gives the means to track progress of a file-stream.

@terjeto
Copy link
Author

terjeto commented Jan 27, 2012

I removed the entire dajaxice.core.js file and produced my own using just a few lines of code which is based on jquery.
I suggest this to be a much more stable and lightweight way...

@nanonyme
Copy link

How are you getting this xhr object in dajaxice? call doesn't return its XMLHTTPRequest at any rate.

@terjeto
Copy link
Author

terjeto commented Mar 20, 2012

I'm not retreiving the XHR object "from" dajaxice. I'm using javascript to access the native browser XHR. (javascript: new XMLHttpRequest)

I beleive dajaxice prototypes the native XHR object, and in this process some of the features of the native XHR object gets lost.
If you have firefox/chrome, open a webpage that uses dajaxice and paste into the browser console:

new XMLHttpRequest().upload ? true :false

You will see that this will result in FALSE which is not correct in a modern browser. (try the same code in a console on this page and you will get TRUE).

Sorry if my explanations are hard to read :-) I can make some screenies if its still unclear.

@nanonyme
Copy link

It seems to me that this is mainly not dajaxice's problem (though it's using an old version of XMLHttpRequest.js which is not good) but https://github.com/ilinsky/xmlhttprequest which doesn't seem to set upload at all. It seems to me the main thing is that dajaxice replaces your browser's XMLHttpRequest with a cross-browser-compatible alternative.

@nanonyme
Copy link

FWIW if you want to check this, try new XMLHttpRequest()._object.upload ? true :false. It should handle with the underlying browser-specific XMLHttpRequest object. Not a production-quality solution, just a note.
I think a better workaround is to make sure DAJAXICE_XMLHTTPREQUEST_JS_IMPORT is false when generating dajaxice.core.js. This will prevent XMLHttpRequest from being replaced.

@terjeto
Copy link
Author

terjeto commented Mar 20, 2012

quote: "It seems to me the main thing is that dajaxice replaces your browser's XMLHttpRequest with a cross-browser-compatible alternative."

Yepp that is it. However I think that a proprietary crossbrowser XHR object is no longer needed as badly as before and could be skipped. As was what I did. Removed the entire dajaxice.js file and replaced with a few lines of jquery.

Why not make dajaxice (js) dependent on JQuery and use JQuery ajax and also JQuery's JSON parser. (I've had several issues with the json parser aswell). Just a thought.. :-)

@nanonyme
Copy link

Well, FWIW I'm not the maintainer... Also that is not a proprietary XHR object. It is LGPL. Using jQuery would most likely be completely overkill for this kind of simple stuff. As said, if you know you're dealing with modern browsers, just disable that variable I mentioned before. Not using the compat XHR might make dajaxice less compatible with old browsers. (I wasn't able to find references to how widely XMLHttpRequestUpload is supported)

@jorgebastida
Copy link
Owner

You can disable the import using DAJAXICE_XMLHTTPREQUEST_JS_IMPORT = False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants