Is jQuery’s $.post method binary safe? Just out of pure interest anyway, so please don’t assume anything.
And if so, are all ajax functions binary safe?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Usually, binary safe means that it isn’t null terminated and any kind of characters can be contained within the strings that are about to be used, mostly just meaning the function can handle any kind of binary data (images, music, etc).
Thing is: you can’t use binary files for AJAX requests. You cannot upload files and you can’t handle a binary file as response (only text output). This isn’t about jQuery, but about the way it works in the lower level. XmlHttpRequest can’t handle such things.
Since the underlying technology doesn’t support binary data for requests or responses, $.post does not either.
Now, on HTML5 we have ways of managing binary data and files for AJAX:
https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
However, this is “new stuff”. So, just wait for it to be supported in multiple browsers and then it might get picked up by frameworks 🙂 For now, only FF supports it (the XMLHttpRequest.prototype.sendAsBinary method). You can get similar functionality on Chrome by using Blobs, but it ain’t the same.