Jump to content

Recommended Posts

Heya, I'm currently brainstorming this little issue of mine, I have my page right, immediately I'm running an ajax request to call a php script but I can't seem to get the URL variables from the actual URL. Is there any way I can access the original $_GET array from the called script ? ( Without having to send the variables again in the request )

 

One way I can do this is via session, but is there an ever easier way?

Edited by Manixat
Link to comment
https://forums.phpfreaks.com/topic/272376-access-url-variables-via-ajax-request/
Share on other sites

Yes, that is an obvious solution, but I am calling this script from every single page on my site and that means I have to go and hardcode all of this into the ajax calls, and if I have to change anything in future that would again mean I have to change everything by hand ( which is actually the same problem with using session ), I was hoping there was another way to access the URL variables from the external script :?

Your PHP script that generates the page, the generated HTML, and your AJAX PHP script are all separate entities. The only communication between them is what information is explicitely sent to each one on an individual basis. I think your initial idea of a session is the best solution to your problem. A session would supersede the need to pass variables between one another.

 

The only information your AJAX script would receive aside from what you pass it would be headers sent from the browser. The 'referer' header might hold the GET variables you are looking for, but these are unreliable since not all browsers are the same and the headers can be easily spoofed.

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.