Return if in jquery

Asked

Viewed 78 times

0

How can I Return this if to pass the value of the page in ajax? The function brings the null value by default. Then I take the if and see and is null it is equal to 1 and if it is greater than the total, will receive the value. But I need to get it to return the ifs values in order to pass the url.

function retorna_cliente(valor) {
  var id_cliente = "";
  var nome_cliente = "";
  var data_nascimento_cliente = "";
  var telefone_cliente = "";
  var celular_cliente = "";
  var cpf_cliente = "";
  var cnpj_cliente = "";
  var endereco_cliente = "";
  var email_cliente = "";
  var cliente = "";
  var mostra_dados_pessoa = "";
  var container_mostra_cliente = $('.mostra_clientes');
  var itemHTML = "";
  var mensagem_cliente = "Nenhum cliente encontrado";
  var quantidade = $("#qtd").val();
  var total_page = "";
  var page = "";

  var total = sessionStorage.getItem('last_page');
  if (valor == null) {
    valor = 1;
  }
  if (valor > total) {
    valor = total;
  }
  alert(valor);

  $.ajax({
        url: url_base + "clientes?qtd=" + quantidade + "&page=" + valor,
        type: 'GET',
        dataType: 'json',
        success: function(data) {
            var retorno = data.clientes.data;
            if (retorno == 0) {
              $('.classe-clientes').css('display', 'none');
              $('.cliente-error-registro').css('display', 'block');
              $('.cliente-error-registro .mensagem-erro').html(mensagem_cliente);
            } else {
              //faz o resto
  • I don’t see any function in that code. You can show more code to understand the framing?

  • @Sergio has already edited

  • True if I give an Else if it already works in Alert it already brings the value. But if I put the online project does not work.

  • 1

    Ajax is inside the function retorna_cliente? this function returns something or is just to send the ajax?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.