Advertisement
corovino

ajax function error

Feb 8th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.37 KB | None | 0 0
  1. $('#register-submit').click(function(){
  2.      
  3.  
  4.       var data= $('#register-form').serialize();
  5.      
  6.         $.ajax({
  7.                  beforeSend:function(){
  8.                     console.log(data);
  9.                  },
  10.                  type:'POST',
  11.                  url:'../Controllers/registro.php',
  12.                  data:data,
  13.                  dataType:"json",
  14.                  success: function(data){
  15.                        console.log('nanananana');
  16.                        console.log("soy data"+data);
  17.                  },
  18.                  error: function(jqXHR, textStatus, errorThrow){
  19.  
  20.                         if (jqXHR.status === 0) {
  21.    
  22.                                 alert('Not connect: Verify Network.');
  23.  
  24.                             } else if (jqXHR.status == 404) {
  25.  
  26.                                 alert('Requested page not found [404]');
  27.  
  28.                             } else if (jqXHR.status == 500) {
  29.  
  30.                                 alert('Internal Server Error [500].');
  31.  
  32.                             } else if (textStatus === 'parsererror') {
  33.  
  34.                                 alert('Requested JSON parse failed.');
  35.  
  36.                             } else if (textStatus === 'timeout') {
  37.  
  38.                                 alert('Time out error.');
  39.  
  40.                             } else if (textStatus === 'abort') {
  41.  
  42.                                 alert('Ajax request aborted.');
  43.  
  44.                             } else {
  45.  
  46.                                 alert('Uncaught Error: ' + jqXHR.responseText);
  47.  
  48.                             }
  49.                      
  50.                  }
  51.  
  52.            });
  53.  
  54.      
  55.  
  56.  
  57.  
  58.  
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement