473,573 Members | 4,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit Formwith AJAX Using ENCTYPE="multip art/form-data"

Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multip art/form-data" (error 500).
Without ENCTYPE="multip art/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.

Here is a part of xmlhttp request where I set header:
....
this.req.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);

Mar 20 '07 #1
4 32506
On Mar 19, 11:07 pm, vunet...@gmail. com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multip art/form-data" (error 500).
Without ENCTYPE="multip art/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.

Here is a part of xmlhttp request where I set header:
...
this.req.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.

Mar 20 '07 #2
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.c omwrote:
On Mar 19, 11:07 pm, vunet...@gmail. com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multip art/form-data" (error 500).
Without ENCTYPE="multip art/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);

Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.
If I submit my form the normal html way, with ENCTYPE="multip art/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multip art/form-data"...
Thanks.

Mar 20 '07 #3
On Mar 20, 8:42 am, vunet...@gmail. com wrote:
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.c omwrote:
On Mar 19, 11:07 pm, vunet...@gmail. com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multip art/form-data" (error 500).
Without ENCTYPE="multip art/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.

If I submit my form the normal html way, with ENCTYPE="multip art/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multip art/form-data"...
Thanks.
Okay, you can't.

Mar 20 '07 #4
On Mar 20, 10:00 am, "Tom Cole" <tco...@gmail.c omwrote:
On Mar 20, 8:42 am, vunet...@gmail. com wrote:
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.c omwrote:
On Mar 19, 11:07 pm, vunet...@gmail. com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multip art/form-data" (error 500).
Without ENCTYPE="multip art/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.
If I submit my form the normal html way, with ENCTYPE="multip art/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multip art/form-data"...
Thanks.

Okay, you can't.
Really? Oh, so you gave me a hint that if I use a hidden iframe to
submit data the normal html way, then it is a solution for me... isn't
it?

Mar 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4181
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens in IE as well as FireFox. This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL 4.1.8 and it works fine. The problem server is...
2
16343
by: Alex | last post by:
Hello, I use the following script inside a page. My page contains : 1 FORM, Some Hidden fields, and one line of JAVASCRIPT in order to instantly post the Form. The problem is that under FIREFOX, the JAVASCRIPT line don't seems to be correct, because FIREFOX does'nt post the Form... But my javascript line looks correct to me... Below is...
2
4223
by: Mr.Clean | last post by:
If I have an Input of type image, it is not listed in the Forms elements when walking to DOM using MSHTML. Is this expected behaviour and how would I get the image input to submit the form NOT using document.form.submit?
5
4570
by: Jeff | last post by:
Visual Studio 2003 DotNet framework 1.1 Windows 2000 Pro I create two pages in an Asp.net application, one is html page with a form in it: .... <form id="testForm" method="post" action="test.aspx" runat="server"> <input type="hidden" id="hiddenTest" value="hello, world"> <input type="submit" id="btnSubmit" value="submit">
23
3608
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it...
1
8009
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html and
5
6403
by: Heofz | last post by:
Hey all, I've been banging my head against a brick wall on this one for the last 12 hours, and the time has come for me to give up and consult the gurus on this one. The below URL contains a login page, you can test it using the details User: marco Pass: polo This seems to work PERFECTLY in opera, and it works in firefox but ONLY if I...
11
1514
by: Jonathan Wood | last post by:
Can anyone point me to any good resources on adding AJAX to a page once the page has already been created? I know VS2008 has options to add AJAX pages, but I didn't select those options when the pages were created. Thanks. Jonathan
14
75467
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post" enctype="multipart/form-data" name="form1"> <select onchange="this.form.submit();" name="prod"> <option value="">Select product</option> <option value="12">abc</option>
1
2258
by: aivanov | last post by:
Hi, I am trying to figiure out why Ajax pop-up window not works with radio button (<input type="radio" onclick="submit()" >). But it works with input type=submit value=value="<?php echo $VM_LANG->_('PHPSHOP_CART_ADD_TO') ?> ). If There is button when user click on it the pop-up messege will come up and user stays at the same webpage. ut...
0
7789
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.