On Mar 10, 2011, at 9:00 AM, Keith wrote:

I am new to prototype JS library feature.

I want to implement ajax upload feature in my web application. For
that,

1) I wrote a servlet which copies the file to a particular folder in
server.
2) HTML form, I have a upload control and a Button which fires an ajax
request. Below is the code on the button

new Ajax.Request('http://isgdev.synygy.net/servlet/
CommonsFileUploadServlet',
{
   method: "post",
     onSuccess: function(transport){
     var response = transport.responseText || "no response text";
     alert("Check-----! \n\n" + response);
   },
   onFailure: function(){ alert('Something went wrong...') }
 });

When I click the button, the servlet is called but the selected file
is not copied to server.

But, When I submit the form, through regular post method (without
using ajax). The servlet works properly and the file is copied to
server properly.

Can you please guide me on this.

Sure. With the exception of bleeding-edge browsers (WebKit nightlies, mostly), JavaScript is prevented from sending files over XMLHTTPRequest for security reasons. Most "Ajax" file uploads fake their way around this by using hidden iframe elements as the actual form target, and a callback from within that iframe to the parent page to handle the response from the server.

Walter


--
You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en .


--
You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to