Search code examples
phpgetjquery-load

Can php get value from another page's url?


I want to use jQuery to make a page partly refresh. Page b is loaded in page a. And page b has a mysql search which gets values depending on a URL rule. So is it possible for PHP to get a value from another page's url? Thanks.

page a:

<script type="text/javascript"> 
    jQuery(document).ready(function(){
        $('#pageContent').load('B.php');
    });
</script>
<div id="pageContent"></div> 

page b:

<script language="JavaScript">
    function pagination(page)
    {
        window.location = "a.php?more="+document.form.more.value;
    }
</script>
<form name="form" action="a.php" method="GET">
<input type="text" name="more" value="<? echo $_GET['more'];?>">
<input type="submit" value="Search">
</form>

Solution

  • Maybe you can try this:

    <script type="text/javascript"> 
        jQuery(document).ready(function(){
            $('#pageContent').load('B.php?var1=test&var2=test');
        });
    </script>
    <div id="pageContent"></div> 
    

    page B

    <script language="JavaScript">
        function pagination(page)
        {
    
            window.location = "a.php?var1=<?php echo $_GET['var1'];?>&var2=<?php echo $_GET['var2'];?>&more="+document.form.more.value;
        }
    </script>
    <form name="form" action="a.php" method="GET">
    <input type="text" name="more" value="<? echo $_GET['more'];?>">
    <input type="submit" value="Search">
    </form>