-1

Here I have an < a ... onclick='show(); / a >. I want to add my php code to to js function, I mean to get action after click.

include($_SERVER['DOCUMENT_ROOT'] . '/model/action.php');
?>

I'm going to put php code in this script

<script>
 document.getElementById("show").onclick = function() {show()};
 function show() {
  document.getElementById("numb").style.display="block";

<<<HERE>>>

}

</script>
1
  • What’s the question here? Did your attempt work? Commented Oct 6, 2019 at 22:36

1 Answer 1

1

With the addition of jQuery you can use ajax function to call a php script

<script>
$.ajax(
  'request_ajax_data.php',
  {
      success: function(data) {
        alert('AJAX call was successful!');
        alert('Data from the server' + data);
      },
      error: function() {
        alert('There was some error performing the AJAX call!');
      }
   }
);
</script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.