Guest User

Untitled

a guest
Jan 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <input type="text" id="testo">
  2. <button type="submit" onclick="send()">Invia</button>
  3. <script type="text/javascript" src="send.js"></script>
  4.  
  5. function send(){
  6. const valore = document.getElementById("testo").value
  7. post('/send', {valore})
  8. window.open("/url", "_self", false)
  9. }
  10.  
  11. function post (path, data) {
  12. return window.fetch(path, {
  13. method: 'POST',
  14. headers: {
  15. 'Accept': 'application/json',
  16. 'Content-Type': 'application/json'
  17. },
  18. body: JSON.stringify(data)
  19. })
  20. }
  21.  
  22. app.get('/', (req,res)=>{
  23. res.render('index.ejs')
  24. })
  25.  
  26. app.post('/invio', (req,res)=>{
  27. valore = req.body.valore
  28. app.get('/url', (req,res)=>{
  29. res.render('testo.ejs', {valore: valore})
  30. })
  31. })
  32.  
  33. <%= valore %>
Add Comment
Please, Sign In to add comment