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'>";
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.