Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the formajax01.tcl example script |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bc899245ccf25ee7cb00ed73a0567f6c |
User & Date: | drh 2018-01-29 00:40:33.888 |
Context
2018-01-29
| ||
00:45 | Move the "env.tcl" example script into the examples/ folder. (check-in: afbbaffbe0 user: drh tags: trunk) | |
00:40 | Add the formajax01.tcl example script (check-in: bc899245cc user: drh tags: trunk) | |
2018-01-28
| ||
22:58 | Add the "env.tcl" demonstration and prototyping script. (check-in: 441f956cf2 user: drh tags: trunk) | |
Changes
Added examples/formajax01.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # This script demonstrates how to send form data as JSON using # XMLHttpRequest # package require wapp proc wapp-default {} { wapp-trim { <h1>Example Of Sending Form Data As JSON Using AJAX</h1> <form id="nameForm"> <table border="0"> <tr><td align="right"><label for="firstName">First name:</label> </td> <td><input type="text" id="firstName" width="20"> <tr><td align="right"><label for="lastName">Last name:</label> </td> <td><input type="text" id="lastName" width="20"> <tr><td align="right"><label for="age">Age:</label> </td> <td><input type="text" id="age" width="6"> <tr><td><td><input type="submit" value="Send"> </table> </form> <script> document.getElementById("nameForm").onsubmit = function(){ function val(id){ return document.getElementById(id).value } var jx = { "firstname":val("firstName"), "lastname": val("lastName"), "age": val("age") } var xhttp = new XMLHttpRequest(); xhttp.open("POST", "%string([wapp-param BASE_URL])/acceptjson", true); xhttp.setRequestHeader("Content-Type","text/json"); xhttp.send(JSON.stringify(jx)); return false } </script> } } proc wapp-page-acceptjson {} { puts "Accept Json Called" puts "mimetype: [list [wapp-param CONTENT_TYPE]]" puts "content: [list [wapp-param CONTENT]]" } wapp-start $argv |