nifCody
nifCody

Reputation: 2444

passing a JavaScript variable to PHP method without using Ajax

I have try to pass a java script variable to PHP method from this way. But I have done wrong way. How do implement it in a correct way.

<script>
       function showMe(id){
           var name = <?php findDriverName(id,$drivers); ?>             
       }
</script>

The variable id is the Java Script Variable I need to pass this to PHP method findDriverName

Upvotes: 0

Views: 817

Answers (1)

dgrundel
dgrundel

Reputation: 568

To get data to your PHP script, it has to be included in an HTTP request somehow. You can store it in a cookie, or do an AJAX request, or do a form POST/GET, but you have to have an HTTP request.

AJAX is your friend here.

Upvotes: 4

Related Questions