how to pass a variable from js to php

0

Hello good afternoon I have the following code that loads me some records, but also what I would like to pass a variable taking advantage of the code.

<script >
   var mivariable=1;
   $(document).ready(function(){
  $("#concepto").load('carga.php');

   });
</script>
    
asked by juan perez 25.11.2018 в 19:14
source

1 answer

3

In js you can concatenate variables using the operator + . Try the following:

...
$("#concepto").load('carga.php?variable='+variable);
...

Then in your php file you can use it with $_GET['variable]

$miVar = $_GET['variable];
    
answered by 25.11.2018 / 19:25
source