Answer the question
In order to leave comments, you need to log in
How to implement SMS-confirmation of registration?
The site is built on Sintra and the actions have the following code:
post '/registration/sms/:number' do
code = Random.rand(1111..9999).to_s
phone = params[:phone].to_s
HTTParty.get('http://sms.ru/sms/send?api_id=' + api_id +'&to=' + phone + '&text=' + code)
# check code
end
%form{:method => "post"}
%div.form-group
%label Телефон
%input#phone.form-control{:name => "phone", :placeholder => "7 950 123 45 67"}
%p.help-block Введите доступный Вам номер, на него будет отправлен код активации
%div.checkbox
%button#sendsms.btn.btn-default{"data-toggle" => "modal", "data-target" => "#myModal"} Отправить
$("#sendsms").click(function(){
var phone = $("#phone").value();
$.ajax({
url: "/registration/sms",
data: {"phone": phone},
type: "post"
})
})
Answer the question
In order to leave comments, you need to log in
The action doesn't need a :number parameter , so it should look like this:
post '/registration/sms' do
# code..
end
var phone = $("#phone").val();
The first thing that catches your eye:
Receive via this route - post '/registration/sms/:number' do
And send via another url: "/coop/sms".
Without debugging, we will not help. There can be many reasons: the SMS-ok apish hangs, the parameters do not come on the backend, the parameters do not take on the frontend.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question