I want to assign JQuery variable to the PHP variable. Any idea kindly
<?php
$phpvariable = jqueryvariable;
?>
The restriction is that you are assigning a value from frontend to backend and this can't be done because php runs at server side while js/jquery runs in the browser.
If you are using ajax then you can use the posted value as:
<?php
$phpvariable = $_REQUEST['jqueryvariable'];
?>
Assume this is the posted data in the ajax:
data:{ jqueryvariable:"theDummyVar" }
or without ajax:
use a <input type="hidden" name="jqueryvariable" value="theDummyVar" />
and post it to the php. This needs to be in the form element.
Why do you need to refer a jquery variable into phpvar? You can just pass the jquery variable via ajax post or you can do it this way.
<?php
$phpvariable = $_POST['textfieldId'];
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.