-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>
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

1 Answers1

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>
Matthew
  • 1,630
  • 1
  • 14
  • 19
CedricYao
  • 167
  • 1
  • 12