A
A
Alexander2018-06-13 14:53:55
JavaScript
Alexander, 2018-06-13 14:53:55

Am I sending the request correctly?

var name = $('#name').val();
$.ajax({
  url: "/api/user.php?action=getlogin&username=name",
  success: function(data) {
    console.log(data);
    var data = data;
    if (data == '{status: 1}') {
    	alert('OK');
    }
  }
});

It always gives out that there is no such user, so I think it's right?
If there is any doubt in the line "url: "/api/user.php?action=getlogin&username=name", Am
I passing the name variable correctly? Or should I not pass it at all in this way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-06-13
@AleksandrB

var name = $('#name').val();
$.ajax({
  url: "/api/user.php",
  data: {'username' : name, 'action' : 'getlogin'},
  success: function(data) {
    console.log(data);
    var data = data;
    if (data.status == 1) {
    	alert('OK');
    }
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question