• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating multipart request using Javascript

 
Tushar Madhukar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can I create a multipart request using Javascript?

I need to create a multipart request where one part has content-type "application/x-www-form-urlencoded" and contains data in name/value pairs (just like query string in GET requests). The other part has content-type "text/xml" and contains an XML document.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't build requests of any kind in JavaScript. The browser does if for you when you submit a form, click a link, redirect to a link, or generate an Ajax request.

What is it that you are really trying to accomplish that can't be handled by a multipart form?
 
Tushar Madhukar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form, which contains several text boxes (for username, password and other things related to my app). Additionally, there is a text area where a user can enter an app-specfic XML. If I set the "enctype" attribute of the form to "multipart/form-data", each of the values entered by the user go into a separate part of the multipart request.

Instead of this, I need the browser to create a multipart request that contains only two part: one part contains the user credentials in name/value pairs, clubbed together using '&' as in query string (say, username=max&password=f245f&...). The other part should contain the XML string.

Since I wasn't able to do this using just the enctype/encoding attributes, I was wondering if Javascript could be used to construct this kind of a request.

Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, JavaScript will not help you.

But why the need to try and change what the browser will submit? Just write your server-side code properly to digest what the browser submits. That's what everyone else does. Why do you need something different?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic