-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow XHR Submissions on forms (#3483)
- Loading branch information
Showing
4 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ app.use('/api/echo/post', function(req, res) { | |
res.end(JSON.stringify(req.body, null, 2)); | ||
}); | ||
|
||
app.use('/form/echo-html/post', function(req, res) { | ||
app.use('/form/html/post', function(req, res) { | ||
var form = new formidable.IncomingForm(); | ||
form.parse(req, function(err, fields) { | ||
res.setHeader('Content-Type', 'text/html'); | ||
|
@@ -72,6 +72,17 @@ app.use('/form/echo-html/post', function(req, res) { | |
}); | ||
}); | ||
|
||
app.use('/form/echo-json/post', function(req, res) { | ||
var form = new formidable.IncomingForm(); | ||
form.parse(req, function(err, fields) { | ||
res.setHeader('Content-Type', 'application/json'); | ||
if (fields['email'] == '[email protected]') { | ||
res.statusCode = 500; | ||
} | ||
res.end(JSON.stringify(fields)); | ||
}); | ||
}); | ||
|
||
// Fetches an AMP document from the AMP proxy and replaces JS | ||
// URLs, so that they point to localhost. | ||
function proxyToAmpProxy(req, res, minify) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters