Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    Finland
    Posts
    488
    Plugin Contributions
    3

    Default jQuery ajax with type POST and securityToken

    Just a little notice for anyone working with jQuery ajax in the admin side. (or probably any type of ajax for that matter that uses POST data instead of GET)

    When using POST to transfer the query to your php script, you need to include the securityToken in the posted data, or else the response will contain the admin index page (with return code 302 for redirect).

    This is of course only valid, if you include the "includes/application_top.php" in the php script.

    Hope this helps someone else not to waste time on debugging :)
    Working with Zen Cart since 2003 :: www.prr.fi
    Author of the original Finnish language pack for Zen Cart since 2004

  2. #2
    Join Date
    Feb 2013
    Location
    Verona, Italy
    Posts
    1
    Plugin Contributions
    0

    Default Re: jQuery ajax with type POST and securityToken

    Hi Pasi!
    Thanks for the advice, I've passed many hours trying out to find the way.. and now it doesn't redirect to home!
    BUT now it shows the "you cannot access to this resource".. how you managed to solve this problem?

    Thank you!

    Jegor

  3. #3
    Join Date
    Mar 2004
    Location
    Finland
    Posts
    488
    Plugin Contributions
    3

    Default Re: jQuery ajax with type POST and securityToken

    I haven't ran across the problem you mention, so can't help you there.

    BUT

    I did find another new fun AJAX feature....

    Debugged this the whole morning..!

    I installed zencart to my developement server and made an addon that uses ajax, which worked fine.

    The code checks if the user is logged in before returning the JSON code.

    Then I uploaded the shop to a live server and edited the config files. Shop is working and the AJAX script is working when I log in and access the ajax handler directly.

    But when accessing the page that has the ajax call it didn't work and the session was terminated (a new session cookie was being set)

    After 3 hours of debugging, I realized that the AJAX query was made to http://www.example.com//test/ajax.php

    and the problem is, the browser doesn't send a cookie to http://www.example.com//test/ajax.php as the shops address is http://www.example.com/test/ajax.php

    eg. it thinks the extra "/" in the URL makes it another domain.

    Hope this helps others :)
    Working with Zen Cart since 2003 :: www.prr.fi
    Author of the original Finnish language pack for Zen Cart since 2004

 

 

Similar Threads

  1. jQuery AJAX Manufacturer Filter
    By rbarbour in forum General Questions
    Replies: 4
    Last Post: 31 Dec 2013, 08:42 PM
  2. Replies: 1
    Last Post: 14 Feb 2013, 09:37 PM
  3. using jquery ajax POST method returning 500 error
    By warroyo90 in forum General Questions
    Replies: 5
    Last Post: 9 Jun 2012, 07:47 AM
  4. securityToken and $zco_notifier
    By jaishem in forum General Questions
    Replies: 1
    Last Post: 16 Mar 2011, 09:49 AM
  5. jQuery to Ajax: how to call application_top.php?
    By joomoo79 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 10 Mar 2010, 09:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR