Passing Javascript value to PHP Variable using ajax
Posted
by
shels
on Stack Overflow
See other posts from Stack Overflow
or by shels
Published on 2012-10-30T04:49:27Z
Indexed on
2012/10/30
5:00 UTC
Read the original article
Hit count: 151
I am trying to use a Flash detection script to assess whether Flash Plugin is enabled in the user browser so that a different page loads. The Flash detection script is as follows, using jquery 1.8.2 and jquery.jqplugin 1.0.2
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="jquery.jqplugin.1.0.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#withflash").hide();
$("#noflash").hide();
if ($.browser.flash == true)
$("#withflash").show ();
else
$("#noflash").show ();
});
</script>
<div id="withflash">Flash Supported</div>
<div id="noflash">Flash Not Supported</div>
I get the display that "Flash Supported" if Flash Plugin is present.. I need to capture the value whether flash plugin value is true in a php variable $hasFlashSupport
as below:
<?php
echo " $hasFlashSupport";
exit;
?>
I am aware that PHP is server based and Javascript is client based.. Hence Ajax would be a nice option to capture the javascript variable to my php variable. I am totally ignorant about Ajax syntax and how to achieve it.
Request the experts here to help me out with the code on how this can be achieved... Thanking all of you in advance..
© Stack Overflow or respective owner