Jump to content

jquery post login form


jalder85

Recommended Posts

Hello,

 

I am trying to put together a jquery post based login form. While the form does post, none of the data portion of the jquery post get executed. If I manually refresh the page after submitting, I am successfully logged in to WHMCS, so that proves that it is posting, but I cannot figure out while none of the function(data) is working.

 

$('#accntlogin').submit(function(){
	$.post('/clients/dologin.php', $('#accntlogin').serialize(), function(data){
		if(data){
			$('#loginform').html(data);
		}
		else{
			$('#forgotpass').show();
			$('#forgotpass').css('color', 'red');
		}
		}, 'html');
	return false;
});

 

Any ideas?

 

Thanks,

 

jalder

Link to comment
Share on other sites

Little bit of an update:

 

Well I found out the reason the post request from jquery isn't coming back successful is because WHMCS is kicking a 302 redirect no matter the query results. So this raises 2 questions:

1. Why isn't post following the redirect for the content?

2. How can I read the full response headers from the post?

 

Jalder

Link to comment
Share on other sites

Finally figured out the cause.

 

The WHMCS login was looking for an https login request only. The development website was not operating under https. Once I forced the redirect to a https connection, the login function worked and the returned data was the redirected page after login instead of the fail.

 

I added some logic to the ajax request and tested the returned data if it contained the loginform or not (if it contained the login form, this would mean that the credentials were bad obviously). I then either loaded the account menu or displayed text to the user that the login was invalid.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated