• Resolved j w

    (@justinmwoodum)


    Can someone explain how a button placed in a post can trigger the content of a widget to be updated – how to request the widget content to refresh? I’ve read the Codex but it’s still unclear. Thanks.

    [FYI, I am replacing a short code and an ID argument with a button. When the button is clicked, the ID argument from the shortcode will display in the widget’s content.]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    There’s a number of ways, one common method is the button click event triggers a javascript or jquery function. This begins an AJAX or similar transaction where the function requests data from your server. If the data is successfully received, it is placed into a DOM container using the innerHTML method or equivalent.

    The only thing the codex is really useful for is how to enqueue javascript and a brief AJAX ovewrview. Turn to the web in general for AJAX techniques, it is not specific to WordPress.

    Thread Starter j w

    (@justinmwoodum)

    Thanks for the great answer, bcworkz!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trigger widget content update via button in post’ is closed to new replies.