O
O
Oleg Galimov2018-01-29 10:47:08
JavaScript
Oleg Galimov, 2018-01-29 10:47:08

How to check ajax connection and request by login and password?

Good time of the day.
Tell me how to check the ajax connection request by login and password getting xml data?
Here is the xml response from the server

<doc lang="ru" func="user">
  <elem>
    <self>on</self>
    <default_access_allow>on</default_access_allow>
    <account_id>5173</account_id>
    <enabled>on</enabled>
    <email>[email protected]</email>
    <realname>Галимов Олег</realname>
    <name>[email protected]</name>
    <id>5176</id>
  </elem>
  <tparams>
    <out>xml</out>
    <func>user</func>
  </tparams>
  <saved_filters/>
</doc>

I did ajax, I need to pull out the email address.
$(function() {
    $('.bill_botton').click(function() {
      var login = $('#authLogin').val();
      var password = $('#authPassword').val();

        $.ajax({
        type: "POST",
        url: 'https://lk.webvm.ru/billmgr?authinfo="'+login+'":"'+password+'"&out=xml&func=user',
        dataType: "xml",
        success: function(data){
        $(data).find('elem').each(function(){
          var xmlEmail =  $(this).find('email').text();
        });
        alert (xmlEmail);
         },
        // если произошла ошибка при получении файла
        error: function(){
          alert('ERROR');
        }
      });
    });
  });

I checked the connection to the login place and set the password to a real value, but there is no result.
I can’t figure out if I’m not selecting the element correctly
Help me figure it out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OKyJIucT, 2018-01-29
@OKyJIucT

$(function () {
    $('.bill_botton').click(function () {
        var login = $('#authLogin').val();
        var password = $('#authPassword').val();

        $.ajax({
            type: "POST",
            url: 'https://lk.webvm.ru/billmgr?authinfo="' + login + '":"' + password + '"&out=xml&func=user',
            dataType: "xml",
            success: function (data) {

                var xmlDoc = $.parseXML(data),
                    xml = $(xmlDoc),
                    xmlEmail = xml.find("email");

                alert(xmlEmail);
            },
            // если произошла ошибка при получении файла
            error: function () {
                alert('ERROR');
            }
        });
    });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question