On a .post, why isn't my .done(), .fail(), and .always() methods working?
None of my alerts in the following code are working?
- <script type="text/javascript">
// Wait until the doc structure is parsed and the browser has created the DOM tree.
jQuery(function() {
// Attach a submit handler to the form
$( "#loginForm" ).submit(function(event) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var userId = $.trim($('#j_username').val());
var pwd = $.trim($('#j_password').val());
var url = 'https://myCompany.com:16399/dummy/index.jsp?skipTutorial=true&tenantId=AA';
alert("UserId: " + userId + ", and password: " + pwd);
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.post( "https://myCompany.uhc.com:16399/dummy/console/j_security_check",
{ j_username: userId, j_password: pwd}, function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
alert( "second finished" );
});
});
});
</script>
Any ideas on what I am doing wrong. I am trying to do an authentication using a java servlet in another web application on the same server. Based upon success or failure I plan on redirecting to the success url, or back to the login page. But I am not able to getting any of the alerts?
Thank You in advance,