Support » Plugin: Ajaxize » apply ajax to a div class?

  • Resolved andrew55

    (@andrew55)


    Great plugin! Is there a method to apply ajax to a div class?

    I use WP Super Cache and I have several forms and other snippets that are dynamic. When a snippet is inserted (into template, pages or post), if this snippet has a div, is there a way to apply ajax to the div? This way, anything in the div wouldn’t be cached.

    The other idea was maybe to use a function to create a custom shortcode. Then, when anything was in this shortcode, the ajax could be applied. I’m not sure if this is possible – just looking for a solution.

    Thanks for any suggestions.

    https://wordpress.org/plugins/ajaxize/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author yoav.aner

    (@yoavaner)

    Hi andrew55,

    The way ajaxize is meant to work is to turn a function to a div. So as long as you can create a simple function that outputs something on the screen (outputs a div, runs a shortcode, anything…) – then you can use ajaxize and convert this function into a dynamic div that is going to be refreshed via ajax.

    Please look at the documentation and examples for more information.

    Cheers,
    Yoav

    Thanks for the reply. I looked and looked through the documentation and support topics (before I made post). I found a lot of helpful things but I’m still a bit confused. Is there an example somewhere of how to apply Ajaxize to a div class so all code within that div will be in ajax?

    I’m somewhat familiar with wp functions (at least where to put them) and can get around in wp templates.

    Thanks for any other suggestions.

    Plugin Author yoav.aner

    (@yoavaner)

    A quick example (but I’m sorry, won’t be able to help further unfortunately):

    inside your functions.php file, add a simple function:

    function my_function() {
      echo '<div>something</div>';
    }

    You can add this function to your templates, but if you’re using caching – it will be cached. If you want to fetch it via ajax, so whatever the function outputs will always be “fresh”, you can use Ajaxize.

    Go to the settings->Ajaxize and enter the function name (in this example, it’s “my_function” without the quotes). Click on “Generate Div”, and then use this div inside your templates, instead of calling the function directly.

    That’s it – from now on, the page will load, and ajaxize will take care of calling the function and generating your div dynamically.

    Hope this helps!

    Cheers,
    Yoav

    Thanks – that helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘apply ajax to a div class?’ is closed to new replies.