PHP
- 6 ответов
- 0 вопросов
3
Вклад в тег
<form name="person">
<input name="name" value="Иван">
<input name="surname" value="Иванов">
</form>
var object = {};
var formData = new FormData(document.forms.person);
formData.forEach(function(value, key){
object[key] = value;
});
var json = JSON.stringify(object);
var xhr = new XMLHttpRequest();
xhr.open("POST", '/submit', true)
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
// Отсылаем объект в формате JSON и с Content-Type application/json
xhr.send(json);
const router = new VueRouter({
routes: [
{ path: '/post/:slug', component: User }
]
})
watch: {
'$route'(to) {
axios.get(`project.com/posts/${to.params.slug}`).then();
}
}
app.post('/comment',function (req,res,next) {
console.log(req.body.email);
res.send('Hello World!');
});