Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. //javascript
  2.  
  3. function verificaCNPJ () {
  4. cnpj = $('#cnpj').val();
  5. $.ajax({
  6. type: "GET",
  7. url: "/verifica/cnpj/" + cpnj ,
  8. success: function (data) {
  9. console.log('Nao cadastrado');
  10. },
  11. error: function (data) {
  12. console.log('Cadastrado');
  13. }
  14. });
  15. }
  16.  
  17. //routes
  18. Route::get('/verifica/cnpj/{cnpj}', 'Controller@verificaCNPJ');
  19.  
  20. //controller
  21.  
  22. public function verificaCNPJ($cnpj) {
  23. $parceiro = Parceiro::where('cpnj', $cpnj)->get();
  24.  
  25. if(count($parceiro) > 0) {
  26. return response('Ja existe', 400);
  27. } else {
  28. return response('Sucesso', 200);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement