Answer the question
In order to leave comments, you need to log in
How to send a post request with VueJS?
Good afternoon, help who than can.
I have a registration form:
<form v-on:submit.prevent="register()" class="form-register">
<div class="login">
<div class="login__text">Логин</div>
<input v-model="dataform.login" type="text" class="login__input">
</div>
<div class="password">
<div class="password__text">Пароль:</div>
<input v-model="dataform.password" type="password" class="password__input">
</div>
<div class="email">
<div class="email__text">E-mail:</div>
<input v-model="dataform.email" type="e-mail" class="email__input">
</div>
<button class="register"><span>Зарегистрироваться</span></button>
</form>
vm = new Vue
el: "#app"
data:
dataform: {}
methods:
register: ->
console.log @dataform
@$http.post("includes/register.php?login=#{@dataform.login}&pass=#{@dataform.password}&email=#{@dataform.email}").then((res) ->
console.log res
(error) ->
alert 'Error')
header('Content-type: application/json');
echo json_encode($_POST);
Answer the question
In order to leave comments, you need to log in
All figured out.
vuejs:
@$http.post("includes/register.php?dataform=", @dataform).then((res) ->
console.log res
(error) ->
alert 'Error')
$json = file_get_contents('php://input');
$data = json_decode($json, JSON_BIGINT_AS_STRING);
print_r($data['password']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question