V
V
Vyacheslav Lebedev2015-06-01 20:55:24
JavaScript
Vyacheslav Lebedev, 2015-06-01 20:55:24

How to pass something to node via ajax?

Good evening!
How to ajax (custom script), pass something to node (express)?
upd : answer

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Lebedev, 2015-06-01
@slavikse

form
        input(type='submit')

$(document).on 'submit', 'form', ->
  $.ajax
    type: 'POST'
    url: '/send'
    data: { test1: 'send', test2: 'send2' }

Node:
  bodyParser = require 'body-parser'
  app.use bodyParser.urlencoded { extended: false }
  app.use bodyParser.json()

  app.post '/send', (req, res) ->
    console.log 'req.body ', req.body

We get what was passed in data.

I
Ivan, 2015-06-01
@LiguidCool

g.zeos.in/?q=node%20js%20post

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question