Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with the php get function?

Tags:

jquery

php

get

i want to pass this paramater topic to another page,

p.s. the page is loaded using jquery?

the url:

http://localhost/final/home.php#page2?topic=jquery

now, i want to echo the the topic on #page2

<h3 class="timeline"><?php echo $_GET["topic"]; ?> </h3>

but it deosnt echo, any solutions, sorry for the newbiw questions :))

load_page.php

<?php
if(!$_POST['page']) die("0");

$page = (int)$_POST['page'];

if(file_exists('pages/page_'.$page.'.php'))
include('pages/page_'.$page.'.php');  // i.e page_2.php

else echo 'There is no such page!';
?>
like image 437
pingpong Avatar asked Feb 26 '23 04:02

pingpong


2 Answers

Your URL needs to be like this:

http://localhost/final/home.php?topic=jquery#page2

Anything after the hash (#) isn't sent by the browser, it's purely for the browser, e.g. scrolling to the correct location, a way to do AJAX history, etc...but it's not sent in the request, currently all your server is getting is:

http://localhost/final/home.php

Which explains why _GET["topic"] is empty.

like image 130
Nick Craver Avatar answered Mar 02 '23 00:03

Nick Craver


remove the php from dataType, and read this read this about datatypes for ajax requests

like image 32
getaway Avatar answered Mar 01 '23 23:03

getaway