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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.