would be possible to pass javascript variable to php and execute function on it and convert it back to javascript
what I want is to get the value on click of an input field and deocode and pass it back
<script type="text/javascript">
$('.my_id').click(function(){
var lv = $('div.special_box form input').val();
var lv = <?php base64_decode( 'here should come my javascript variable' )?>
});
</script>
1 Answer 1
You can't do it as you are asking above. Javascript is a client side language, php a server side language. While there are other methods, you should use AJAX to call a separate page that will simply return the value from the function.
lv = $.ajax({
url: "some.php?lv=" + lv,
async: false
}).responseText;
Sign up to request clarification or add additional context in comments.
2 Comments
bestprogrammerintheworld
Just for clarification, the php-file must echo out the result. this solution works fine if you only want ONE return-value.
Renegade91127
@bestprogrammerintheworld is correct, although if you needed multiple values, you could always return a parsable string or XML.
default
ajax.