send javaScript variable to php variable

Posted by mrbunyrabit on Stack Overflow See other posts from Stack Overflow or by mrbunyrabit
Published on 2011-11-19T01:19:00Z Indexed on 2011/11/19 1:51 UTC
Read the original article Hit count: 151

Filed under:
|
|
|

First i thought that i had to convert javascript to php, but then i found out that cant because of server and client side executions. So now I simply want to send ONE variable

<script type="text/javascript">
function scriptvariable()
{        
    var theContents = "the variable";
}
</script>

to a php variable

<?php
$phpvariable
?>

That function in the javascript executes when lets say i click on a button.

Now i have Nooo idea how to get that phpvariable Equal to the javascript one so i can use that phpvariable to look up stuff in my Database. I know i can add it to my url or some thing, and just refresh the page.. But id like to do it with AJAX as further in my webpage i might have to use this Ajax method..

So is there an easy way to do this without having to dump pages of code on my page to do one simple thing?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript