Хочу отправить асинхронний post-запрос с ajax на сервер nodejs, но не получается. Подскажите кто можеть
var xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax', true);
xhr.send();
Выдается такая ошибка на браузере:
(index):215 POST
localhost:8081/ajax 404 (Not Found)sendText @ (index):215document.forms.form.send.onclick @ (index):233
(index):215 XHR finished loading: POST "
localhost:8081/ajax".
И вот такая на сервере
TypeError: Cannot read property 'parent' of undefined
at Function.exports.update (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\cheerio\lib\parse.js:55:25)
at module.exports (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\cheerio\lib\parse.js:17:11)
at Function.exports.load (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\cheerio\lib\static.js:19:14)
at Request._callback (c:\Users\JAHONGIR-PC\WebstormProjects\translator\hw4\myapp.js:55:25)
at self.callback (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\request\request.js:200:22)
at emitOne (events.js:90:13)
at Request.emit (events.js:182:7)
at Request.init (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\request\request.js:288:17)
at new Request (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\request\request.js:142:8)
at request (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\request\index.js:55:10)
at c:\Users\JAHONGIR-PC\WebstormProjects\translator\hw4\myapp.js:53:5
at Layer.handle [as handle_request] (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\express\lib\router\layer.js:95:5)
at next (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\express\lib\router\layer.js:95:5)
at c:\Users\JAHONGIR-PC\WebstormProjects\translator\node_modules\express\lib\router\index.js:277:22