retrieving $_GET variable in jquery


I have a main page (topic.php) with GET information in the URL, like this:<br />


I have a div, "currLeader" in topic.php into which I load another page, getCurrLeader.php. getCurrLeader.php is supposed to use the topic variable in the $_GET info of the url to do a mysql search and return the relevant info. The problem is that while, scripts on topic.php are able to successfully use extract($_GET), I am not able to retrieve any variables out of the getCurrLeader.php extract($_GET) statement. I thought both pages would be able to access the currently showing url. Is there another way I can get this information out of the current url?

(consequently, the "topic" info is actually present in an element with an id on the page, and I'm able to successfully retrieve it using jquery, but I can't figure out a way to then, within the same file, pass that value to my php script).


I'm not really sure I understand what you're asking. On first read I assumed you were trying to do this with jquery, but now I'm not so sure I'm on the same page at all. Here's an easy way to extract the parameters in javascript:

<script type="text/javascript"> var ourlocation = location.href; var thisstuff = ourlocation.split("?"); var id = thisstuff[1]; var idary = id.split("&"); var param2 = idary[0]; var param3 = idary[1]; var param4 = idary[2]; </script>

Which probably has nothing to do with what you're trying to do.

On 2nd read it seems like you're trying to get the originating url in a php script, when another one loads first.

One way you could do that is use sessions. Either store the parameters you're trying to extract, and stuff them in a session to be retrieved by the other file, or you could actually just store the url itself, then pull it out and split it.

session_start(); $_SESSION['ourUrl'] = $_SERVER["REQUEST_URI"]; // do stuff on next page unset($_SESSION['ourUrl']); session_destroy();

If none of this makes sense feel free to explain further and we'll see if we can get you going. Hopefully this helps a little.


  • file_get_Contents won't send query strings in url , thus receiving nothing with $_GET
  • Index.php as custom error page
  • python: forcing relative imports to search from script file
  • Python 3.2.2, error(scripts to exe)
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • Why must we declare a variable name when adding a method to a struct in Golang?
  • Python ImageIO Gif Set Delay Between Frames
  • MYSQ & MVC3 SQL connection error \\ ProviderManifestToken but I am using MySQL
  • Invalid object name 'dbo.Item'
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • TextToSpeech.setEngineByPackageName() triggers NullPointerException
  • Textfile Structure (tables)
  • Test if a set exists before trying to drop it
  • Moving mysql files across servers
  • Google Custom Search with transparent background
  • How to rebase a series of branches?
  • Insert into database using onclick function
  • What is Eclipse's Declaration View used for?
  • PHP - How to update data to MySQL when click a radio button
  • req.body is undefined - nodejs
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • How to check if every primary key value is being referenced as foreign key in another table
  • Join two tables and save into third-sql
  • Can I make an Android app that runs a web view in Chrome 39?
  • How to model a transition system with SPIN
  • Upload files with Ajax and Jquery
  • Weird JavaScript statement, what does it mean?
  • ORA-29908: missing primary invocation for ancillary operator
  • How do you troubleshoot character encoding problems?
  • How to format a variable of double type
  • Comma separated Values
  • Append folder name and increment by 1 using batch script
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • Converting MP3 duration time
  • How to push additional view controllers onto NavigationController but keep the TabBar?