O
O
Oleg Galimov2018-01-30 12:18:26
JavaScript
Oleg Galimov, 2018-01-30 12:18:26

How to get variable from ajax request?

Good time of the day.
Tell me how to pull out a variable from ajax request xml value?
Here is Ajax

$.ajax({
    type: "POST",
    url: "https://lk.webvm.ru/billmgr?authinfo="+$login+":"+$password+"&out=xml&func=user",
    dataType: "xml",
    success: function(xml) {
    xmlDoc = $.parseXML( xml ),
    $xml = $(xmlDoc),
    $email = $xml.find("email").text();
    alert($email);
    },
            // если произошла ошибка при получении файла
            error: function () {
                alert('ERROR');
            },
      complete: function() {
        $('#result').append('<div class="user_info">'+$email+'<div>');
      }
});

I can't print the value ("email").text(); the alert comes out empty with no value and the block does not display a value.
How to take out the value?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Galimov, 2018-01-30
@olegalimov

Thank you all! found a solution by typing.
Maybe someone will need it.

$.ajax({
type: "GET",
url: "https://lk.webvm.ru/billmgr?authinfo="+$login+":"+$password+"&out=xml&func=user",
dataType: "xml",
success: function(xml) {
//console.log(xml);
$email = $(xml).find('email').text();
$('#result').append('<div class="user_info">'+$email+'<div>');
}
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question