Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. var buscarProduto = $(this).val();
  2. var idcategoria = $(".active-button").attr("id");
  3. var mostraPesquisa = "";
  4.  
  5. if(buscarProduto.length == 0)
  6. {
  7.  
  8. $('.item-selecionado').fadeIn();
  9. }
  10. else
  11. {
  12.  
  13. $.ajax({
  14. url: 'http://api.teste/store/produtos?filter[categoria_id]=' + idcategoria + '?like[nome]=' + buscarProduto + '',
  15. method: 'GET',
  16. dataType: 'json',
  17. success: function(retorno)
  18. {
  19.  
  20. $.each(retorno.data, function(i, item)
  21. {
  22. alert(item.nome);
  23. // mostraPesquisa += '<li class='item-pesquisado'><span class=''>Nome do Lanche</span></li>';
  24. })
  25.  
  26. $('.item-selecionado').fadeIn();
  27. $('.item-selecionado').html(mostraPesquisa);
  28. },
  29. error: function(XMLHttpRequest, textStatus, errorThrown)
  30. {
  31. alert("Status do Servidor: " + textStatus);
  32. alert("Erro do Servidor: " + errorThrown);
  33. }
  34. });
  35. }
  36.  
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement