WordPress.org

Ready to get started?Download WordPress

Forums

ajax call to a php class but can't access the class variables (2 posts)

  1. cw6365
    Member
    Posted 3 years ago #

    This is a bit hard to explain

    I have made a checkout style plugin that gets the post and begins a payment process.

    A new object is created by the plugin called say '$object' and the checkout is started by calling $object->start($postid) by which the class vars are set eg $postidVar.

    During the checkout process i use an AJAX call which calls a method within the $object class, which again works fine. The problem i'm having is that inside this method i can't access any of the class variables eg $object->postidVar; to use within this method. They output in methods called before and after the ajax function is called but not during.

    Is it something to do with because i'm calling the method outside from a click handler which is using the previously set add_action function to call the method in the class that it is not recognizing the previously set post variables, but the method is called from the previously created object reference eg

    add_action('wp_ajax_update_planner', array($filmCheckout, 'update_planner'));

    i'm at a loss, if anyone could steer me in the right direction that would be great.

  2. Maruti Mohanty
    Member
    Posted 2 years ago #

    Its been very long since you posted.

    I have faced a similar problem. But I was not able to use previously used variables in the newly rendered file.

    For this you need to include wp-load.php into the new file.

    It worked for me.

    Make sure you give the write path to the file.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.