Jump to content

How to pass php variable from one file to another with jquery ?


Glenskie

Recommended Posts

Okay so i have a file that i need some php variables from. This is the code that i am using. please help !

 

This is the ajax that i am trying to use to get the variable and then set it to a php variable.

 

$.ajax({
        url : 'pagination_data.php?page=1',
        type : 'POST',
        data : data,
        dataType : 'json',
        success : function (result) {
            var k=result;
            <?php $next ?>=var k;
        },
        error : function () {
           alert("error");
        }
    });

Now here i am setting the varialbes in the other file.

$next = $page+1;
$prev = $page-1;


echo json_encode($next);
echo json_encode($prev);

and this is where i need the variables... 

<?php


echo "<div class='controls' id='$prev'></div><div class='controls' id='$next'>";
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.