0

Есть ajax запрос:

$.ajax({
    type: 'POST',
    url: 'http://142.20.99.99:8081/pggrw/v1',
    xhrFields: {
        withCredentials: false
    },
    crossDomain: true,
    data: JSON.stringify({
        "method": "subscriberInfo",
        "params": [{ "msisdn": "99999999" }],
        "id": "1"
    }),
    success: function (msg) {
        var data = JSON.stringify(msg);
        $('#go').html(data);
    },
    error: function (responseData, textStatus, errorThrown) {
        console.log('POST failed.');
    },
    dataType: 'json',
    contentType: "application/json; charset=utf-8"
});

Как передать параметр "msisdn" из инпута через форму в параметры post, при этом остальные данные не меняя.

1 ответ 1

1

ищем инпут

var input = document.getElementById('my-input-id'); // по id

или

var input = document.querySelector('my-input-class'); //по классу

возможно вы любым другим способом "прицелитесь" к инпуту. Может через data атрибут. Далее вставляем значение в параметры:

"params": [{ "msisdn": input.value }],

должно работать)

1
  • Большое спасибо @Taarim, очень помогли. 25 апр 2018 в 13:23

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.