I would like to send a php value with this function
$k = $_GET['k'];
function getData() {
$.post('page.php', {
action : 'loader',
number : $settings.nop,
offset : offset,
//I LIKE TO SEND $k
}
I would like to send a php value with this function
$k = $_GET['k'];
function getData() {
$.post('page.php', {
action : 'loader',
number : $settings.nop,
offset : offset,
//I LIKE TO SEND $k
}
PHP is a server side language and JS is a client side language So this variable is not directly accessible in javascript which can be sent in an ajax request.
So from php side you can expose this variable $k
using a global variable and then send it in the ajax call from Js like this
<script type="text/javascript">
window.myGlobalVariable = "<?php echo $_GET['k'] ?>"
</script>
Now you can send it in JS like this.
function getData() {
$.post('page.php', {
action : 'loader',
number : $settings.nop,
offset : offset,
variable : myGlobalVariable //Value of myGlobalVariable will be set by PHP code
}