here is the issue this is my query
SELECT * from employee_leaves
WHERE employee_leave_company_name ='$sup_company_name' AND leave_status='Pending'
ORDER BY employee_leave_id desc";
the problem here is employee_leave_company_name
is stored in php variable $sup_company_name
in my file require.php
so how should i access that variable in my javascript
this is what i have done so far
var cmpny_name;
var reqData=["c_name" : "sup_company_name"];
var xhrObj = $.get("require.php",c_name)
.done(function( response ) {
cmpny_name=response;//The echo text from server
})
.fail(function() {
alert('error');
});
but this isnt working.... and here is my php code from require.php
$sup_company_name=$_SESSION['employee_company_name'];
Try this
var cmpny_name;
var reqData=["c_name" : "<?php echo $sup_company_name; ?>";
var xhrObj = $.get("require.php",c_name)
.done(function( response ) {
cmpny_name=response;//The echo text from server
})
.fail(function() {
alert('error');
});
Other than this, if you really want to interact between PHP and JavaScript you should use Ajax.
You must "pass" the php var value to the "client side"... so for example print a hidden input with the value in order to use then with js or something like that.
<input type="hidden" id="hiddenval" name="hiddenval" value="<?php echo $sup_company_name; ?>" />
and then get the value from this element with js.
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.