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);
           }
       }

 });

Comments

Popular posts from this blog

Read Images from a xlsx file using Apache POI

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

How to create mail message in FRC822 format