Issues When Trying to Use Multipart-Form Data with Jquery AJAX Forms

Let me first set the background for this discussion. I have a client that wants to ask for some information like name, address, education, etc. and wants them to attach a document. They want the content form and the file to be attached to an email and sent to a recipient. At first this seemed no problem but then the requirements where added that required all of this to happen using jquery and ajax. (This seems more professional) This completely changed everything. This article along with the next few articles will go through the thought process of some “catchas” and how they were solved. I realize that someone might have a better “mousetrap” but this is how I accomplished it. I spent a lot of time on Google and reading a lot. Articles like…

But (as typically the case) each one did not exactly fit what I needed.
Here are the challenges and restrictions that I had to overcome.

  1. All the samples presented were in C+ and in many cases use MVC (Creates problems if you have to use VB and web.api’s)
  2. Not all people will use the latest browser. (Using FormData vs. Creates problems trying to use formvar oMyForm = new FormData(); and cross-scripting calls)
  3. Need to use async uploading. (Creates problems trying to use standard multi-part form functionality in html)
  4. There is more than just a file begin sent. (Creates a problem with parsing the file from the form-data)
  5. Document attachment cannot be saved to web site (Creates a problem with attaching a document to an email).
  6. I have to use Visual Basic without MVC (Creates a problem with using above solutions)
  7. Cannot use Json responses because of using HTTPResponse (Creates a problem with older browsers)

Within each of these restrictions, I had even more challenges but I can say that I have overcome them and hopefully help someone else.
Over the coming weeks I will be addressing each of these restrictions and how I solved them. I want to thank each of the authors above mentioned articles for without them this would have taken me a lot longer to figure out.

Note: As I complete each resolution I will provide a link to that article. As always please drop a note if you see some area that I can improve in and I will make note of it.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , | Posted under ASP .NET 4.0, Programming/Coding | RSS 2.0

Author Spotlight

David Bauernschmidt

I live in the historical triangle of Virginia where I am married with two daughters. I have spent over 13 years working for a Fortune 500 company in the computer area. I started in VB 6.0 and by the time I ended my employment I was supervising a development team where we built many web applications. When my first daughter was born I wanted to spend more time with her so I left and became a programmer analyst for local government as well as launch my own company. Since then I have grown James River Webs into a profitable web design and application company helping small businesses create a big presence on the internet. As an employee I have created web application used by citizens and other companies. I enjoy fly fishing, and spending time with my family. I also enjoy learning new approaches and development tools when it comes to developing applications.

Leave a Reply

Your email address will not be published. Required fields are marked *