T
T
TchernyavskyDaniil2017-09-15 10:51:36
JavaScript
TchernyavskyDaniil, 2017-09-15 10:51:36

VK API, why can't send a message?

Good morning. Please help, I don't understand why I can't send a message to a user from my friends list. I would be very grateful for help in this stupid question.
When I click on the "Send message" button, the console navigates to and redirects to the api.html start page and at the end of the link "?". in the data-uid database, IDs are not recorded at all, I looked. He seems to be skipping that part. Is it because of the version?
The function of sending a message

<div class="friends__text">
          <input type="text" required>
          <div class="label-box">
                        <label>Введите Ваше сообщение</label>
                    </div>
        </div>
        <button id="send-message" class="detail__btn">Отправить сообщение</button>

$('#send-message').on('click', sendMessage);
    function sendMessage(event) {
      var uid = +$(event.target).attr('data-uid'); 
      var value = $('input').val();

      if (!value) {
        alert("Не ввели сообщение");
        return;
      }

      sendRequest('messages.send', {user_id: uid, message: value}, function() {
        console.log('Отправлено');
      });
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2017-09-15
@vshvydky

I may be a little on the topic, but two questions
1. As I understand it, this is a front-end code, why the hell are you fumbling a token there? (By the way, you also set it on fire on the toaster, the very thing is to change the password until you get spammed).
2. Are you sure that cross-domain requests for API VK are allowed? I think that a nasty exception about allov origin falls into your console

T
TchernyavskyDaniil, 2017-09-15
@TchernyavskyDaniil

Decided to preventDefault

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question