Ajax request using jquery


$.ajax({
      type : "POST",
      url : "/login",
      cache: false,
      data : {userId:'test-user' , timestamp:'20121119'},
      dataType: 'json',
      success: function (data) {    
          $.each(data, function(index, element) {          
         alert(index+" and "+element);
          });
       
      },
      error: function(jqXHR, exception) {
           if (jqXHR.status === 0) {
               alert('Not connect.\n Verify Network.');
           } else if (jqXHR.status == 404) {
               alert('Requested page not found. [404]');
           } else if (jqXHR.status == 500) {
               alert('Internal Server Error [500].');
           } else if (exception === 'parsererror') {
               alert('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               alert('Time out error.');
           } else if (exception === 'abort') {
               alert('Ajax request aborted.');
           } else {
               alert('Uncaught Error.\n' + jqXHR.responseText);
           }
       }

 });

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Android: where to run keytool command in android