Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Submit main_login_form with AJAX Rate Topic   - - - - -

 
  • JNizhnik
  • Member
  • Members
  • Join Date: 16-Feb 10
  • 31 posts

Posted 13 April 2010 - 04:40 AM #1

So I'm trying to submit the login form in the background using AJAX but am having little to no luck. Essentially what I'm trying to do is to log into my store from another part of my site running under my CMS.

When I write up the HTML for the form with the same elements and hit submit, everything works fine. With the return_url argument I even come back right to the page where I started as if I never left. You can immediately see that a cookie has been set and if you navigate to the store you are logged in with no issues.

Take that same exact code and bind the submit button to jquery and send it in the background using an AJAX POST method and you get a 404 on /store/index.php.

Any thoughts? Are there better ways to do this to begin with? Also are there any AJAX log in mods, maybe I can look at how they have done it.

Thanks,

Joe

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,818 posts

Posted 21 April 2010 - 10:25 PM #2

You need to ensure that whatever backend method you are using setups up browswer impersonation correctly. Otherwise it will fail.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • TexasGuy
  • Senior Member
  • Members
  • Join Date: 18-Mar 10
  • 546 posts

Posted 26 April 2010 - 03:22 PM #3

Better use ajax to drive your own PHP file that curls into the cart. Much less headache.
PM me today for design/coding projects :P

 
  • abcd
  • Member
  • Trial users
  • Join Date: 10-Sep 16
  • 48 posts

Posted 13 September 2017 - 05:06 AM #4

I want to add ajax on login form submission so that if the login credentials are wrong then the invalid credentials notice will appear on login popup only and not homepage.

Can anyone help me please?

Thank you!!



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,635 posts

Posted 13 September 2017 - 07:16 AM #5

I want to add ajax on login form submission so that if the login credentials are wrong then the invalid credentials notice will appear on login popup only and not homepage.

Can anyone help me please?

Thank you!!

 

At first, add cm-ajax class to the authorization form

 

design/themes/THEME/templates/views/auth/login_form.tpl

 

Then correct the controller

 

app/controllers/common/auth.php

 

Do not forget to add area and ajax request condition. E.g.

if (AREA == 'C' && defined('AJAX_REQUEST')) {
    ....custom code here....
}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • abcd
  • Member
  • Trial users
  • Join Date: 10-Sep 16
  • 48 posts

Posted 14 September 2017 - 09:01 AM #6

 

At first, add cm-ajax class to the authorization form

 

design/themes/THEME/templates/views/auth/login_form.tpl

 

Then correct the controller

 

app/controllers/common/auth.php

 

Do not forget to add area and ajax request condition. E.g.

if (AREA == 'C' && defined('AJAX_REQUEST')) {
    ....custom code here....
}

Can u please explain in brief what will be there in custom code part??



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,635 posts

Posted 14 September 2017 - 01:55 PM #7

Can u please explain in brief what will be there in custom code part??

 

Just check if there is any error and output error message, when use exit php  function to stop further redirects


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия