Jump to content

Is it possible to retrive javascript varaibles inside of php only?


t3hmadhatt3r

Recommended Posts

I am trying to get javascript variables using only php. I'm not sure if this is possible but, If it is help will be very, very appreciated. This should explain what I'm trying to do:

 

<?php
$data = javascript:data;
?>

 

I know the above code doesn't work. It's just a explanation. Thanks in advance.

Link to comment
Share on other sites

PHP lives on the server, JavaScript lives on the client.  The only way the client sends information to the server is via HTTP requests; an HTTP request always has a URL and can optionally have GET or POST data.

 

Therefore if you want to send data from JavaScript to PHP (i.e. from client to server), then you must make an HTTP request (using XHR).  Your request can put the information anywhere you'd like it to be:

1) The URL

2) GET

3) POST

 

Your PHP script should grab the data from wherever your JavaScript placed it; if you'll need it in a future PHP script request, then look at storing it in a SESSION.

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.