Posts

Showing posts with the label ajax file

FormData, send file with ajax, send ajax with a file, explanation, tutorial, and example, in c# asp.net

so... this will be the table of content for everything i wrote in this long, long title FormData simple overview the most simple way to define it is, as simple as that, do a full postback without a postback, just with ajax. usually you'll need it in 2 scenarios - (a) uploading file/s, maybe with other properties. (b) security won't let you do JSON. so what i made for you? 1. Detailed simple explanation about the examples in developer.mozilla.org docs, its a bit hard to get examples . 2. Detailed simple explanation and example about how to make it more JQuery and generic 3. Simple explanation and example about how to use it with a C# handler HF!!

Detailed simple explanation about the examples in developer.mozilla.org docs, its a bit hard to get examples

have you read this  https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Submitting_forms_and_uploading_files ? or the more basic one  https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects ? a bit hard and un-copy-pasteable. after that you may read my own a bit more generic exmamle . so lets start with the 2nd link , which is supposely simple, but there are a couple of catches. 1st, although it says, you can only create a FormData with a form element, which is a bit problematic in many cases where you can only have 1 form like in asp.net or sharepoint. the solution will be presented down here with the explanation about the upper link, and in a more generic example in my other post here 2nd is in the jquery example, where they say you can turn off the proccessData and contentType, which although true, but that means you need to break the request hardcoded, and that in managed frameworks you'll get the raw st...