When I clicked the button the it will not work to post a data to mysqli. Why?

$(document).ready(function() {
  $("#switch<?php echo $id ?>").click(function() {

    var status = $('#status<?php echo $id ?>').val();
    var id = $('#p_id<?php echo $id ?>').val();

    $.post("action.php", {
      status: status,
      id: id
    });
  });
});

1 Answers

1
Community On
You can use + operator for concat the value.

$(document).ready(function() {
      $("#switch"+<?php echo $id; ?>).click(function() {
        var status = $('#status'+<?php echo $id; ?>).val();
        var id = $('#p_id'+<?php echo $id ?>).val();
        $.post("action.php", {
          status: status,
          id: id
        });
      });
    });