Sunday, July 24, 2022
HomeWordPress DevelopmentWordpress Ajax Not Firing - WordPress Growth Stack Alternate

WordPress Ajax Not Firing – WordPress Growth Stack Alternate


I have been out of the WordPress sport for some time now and I am simply getting again into it. I am making an attempt to apply calling a PHP perform by way of Ajax however I am not capable of get the Ajax name to even fireplace (when checking in Google Chrome Developer).

I’ve obtained a humorous feeling that this will have one thing to do with the place I’m including the code. At the moment I am simply including all this in a HTML block verbatim as per beneath however I’ve obtained a humorous feeling that this can be the problem?

Do I would like so as to add the javascript by way of a plugin or comparable?

My easy instance is as follows:

<div id="output_div">
   <p>That is the place output ought to go</p>
</div>

<choose title="player_ID" id="player_ID">
  <choice worth="player1">player1</choice>
  <choice worth="player2">player2</choice>
</choose>

<script kind="textual content/javascript">
jQuery(doc).prepared(perform ($) {
    var valueCheck;
    jQuery("#player_ID").on("change", perform () {
        jQuery.ajax({
            kind: "POST",
            url: "/wp-admin/admin-ajax.php",
            information: {
                motion: "practice_ajax_function"
            },
            success: perform (output) {
                jQuery("#output_div").html(output);
            }
        });
    }).change();
});
</script>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments