May 2017
Beginner to intermediate
536 pages
14h 25m
English
Once the author clicks the button, the status has to be saved to the database as true or false depending on the current status of the answer. Let's go through the jQuery code located inside the questions.js file for making the AJAX request to the server:
jQuery(document).ready(function($) { $(".answer-status").click( function() { $(body).on("click", ".answer-status" , function() { var answer_button = $(this); var answer_status = $(this).attr("data-ques-status"); // Get the ID of the clicked answer using hidden field var comment_id = $(this).parent().find(".hcomment").val(); var data = { "comment_id":comment_id, "status": answer_status }; $.post( wpwaconf.ajaxURL, { action:"mark_answer_status", nonce:wpwaconf.ajaxNonce, ...Read now
Unlock full access