Good morning,
Is there a good way to use JavaScript to send a form submission, but get
back the response as a string, rather than loading it into a page? I
could write the code to send the submission via XMLHttpRequest, but that
seems hard... especially implementing multipart-encoded form submission
such as required for file upload.
Ideas?
-- www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation 3 1915
Chris Smith wrote: Good morning,
Is there a good way to use JavaScript to send a form submission, but get back the response as a string, rather than loading it into a page? I could write the code to send the submission via XMLHttpRequest, but that seems hard... especially implementing multipart-encoded form submission such as required for file upload.
Ideas?
You might want to have a look at kupu (SVN checkout from http://codespeak.net/svn/kupu/trunk/kupu) and search for kupu_upload_for m.
The form there has a target attribute and is followed by an invisible
iframe with a name matching the target. When the form is submitted, this
means the response comes back into the iframe. The response includes an
onLoad event which calls a javascript method back in the main document to
handle the result or display an error message.
Duncan Booth <du**********@i nvalid.invalid> wrote: You might want to have a look at kupu (SVN checkout from http://codespeak.net/svn/kupu/trunk/kupu) and search for kupu_upload_for m.
The form there has a target attribute and is followed by an invisible iframe with a name matching the target. When the form is submitted, this means the response comes back into the iframe. The response includes an onLoad event which calls a javascript method back in the main document to handle the result or display an error message.
That would work... except that I don't have any control over the form
tag... and the form needs to work as usual when the real submit button
is pressed. I suppose I could temporarily set the target via DOM, and
then put it back after the Form.submit() call... seems kinda kludgy,
though. I'm debating whether that's cleaner than faking the form submit
via XMLHttpRequest.
-- www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Chris Smith wrote: Duncan Booth <du**********@i nvalid.invalid> wrote: You might want to have a look at kupu (SVN checkout from http://codespeak.net/svn/kupu/trunk/kupu) and search for kupu_upload_for m.
The form there has a target attribute and is followed by an invisible iframe with a name matching the target. When the form is submitted, this means the response comes back into the iframe. The response includes an onLoad event which calls a javascript method back in the main document to handle the result or display an error message.
That would work... except that I don't have any control over the form tag... and the form needs to work as usual when the real submit button is pressed. I suppose I could temporarily set the target via DOM, and then put it back after the Form.submit() call... seems kinda kludgy, though. I'm debating whether that's cleaner than faking the form submit via XMLHttpRequest.
You may not have to put it back immediately: you just need an onsubmit
handler which works out which way you want to submit the form and direct
the target accordingly.
Alternatively clone the entire form and set the target on the clone. I have
no idea whether you can then submit the clone without adding it into the
DOM. If you can then that would be a nice solution, one call to cloneNode,
set the target and submit. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom |
last post by:
I have created the following code for a product select/payment form (don't know if there is a better
way) and I have been trying to make the following changes (unsuccessfully so far):
1) Eliminate the submit button and submit the form with onchange.
2) Open the action php page in a new window.
I am using this code for different payment options (i.e., cc processing and paypal). As such, there
are multiple forms on the page. The...
|
by: Pete |
last post by:
I have form/select which executes a function using onchange. No
problem. However, when I validate the page with a strict HTML 4.01
doctype at http://validator.w3.org, it demands either an action or a
method for the form?.
If I give it an empty action <form action="" ..... it validates OK. Is
this acceptable or is there a better/standards correct way?
Thanks.
|
by: Richard Cornford |
last post by:
I am interested in hearing opinions on the semantic meaning of FORM
(elements) in HTML.
I have to start of apologising because this question arose in a context
that is not applicable to the Internet. Specifically, marking up a
document that will contain multiple related form controls (intended
exclusively for client-side scripting) that would never be intended to
be submitted. I realise that that concept is a non-starter in an
Internet...
|
by: Andy Goldstein |
last post by:
I have a table where all the TRs have an onClick handler registered.
One (and only one) of the rows has 2 text input boxes, where each
textbox has an onChange handler registered. Both the onClick and
onChange handlers do some minor manipulation of form data (although
they work on different form elements). If the onChange event fires, I
need the form to be submitted. If the onClick event fires for a TR, I
also need the form to be...
|
by: |
last post by:
I am working on a web/webservice application that has a service layer. Most
service methods will perform an access-check before executing. This check
uses the IPrincipal credentials available in HttpContext.Current. This works
great.
My issue is that I need to write unit tests for those service methods. These
tests then run outside of IIS, thus there is no HttpContext.Current
available - and the servicemethod will not execute.
The two...
| |
by: yawnmoth |
last post by:
Say I have the following HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<form action="">
|
by: Oleg Konovalov |
last post by:
Hi,
I have a Java/JavaScript GUI application where I perform a lot of long DB
operations
, which takes 5-60 secs to perform.
Sometimes user double-clicks the button or just gets impatient and clicks
again,
which created duplicate forcm submission and hence duplicate records.
So I am trying to disable the button as soon as it is clicked, and as soon
as it's done,
|
by: Homer |
last post by:
Hi,
I just got a requirement from my HR department to automate their form
submission process and integrate it into the Intranet project that I
had just completed Phase 1 of. Because of the short time frame that
I've been given, a week to be exact, I do not have the luxury to
explore it on my own so here are the requirements:
1. Automate the personnel forms that employees use for changing their
information, which is currently in pdf...
|
by: Megalog |
last post by:
Hey guys.. my turn to ask a question:
I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has no Master/Child relationship set to the main form. Specifically the problem seems to be that everytime the recordsource of the subform is changed, the subform object itself tries to set a default Master/Child value (both fields fill with the "ID"...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |