Your sinatra code expects /registration/sms/:number
, but your ajax sends to /registration/sms
with phone: XXXXX
in the post data.
Change your server code to:
post '/registration/sms' 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