Community & Support

how can I store what jQuery returns in a PHP variable?

I am fairly new to jQuery.

basically I just want to do $('body').width(), which returns the width of the body element. I want to store that in a php variable.
Also if i wanted this in my page.tpl.php how would I go about it.
I know I use something like:

<?php
   drupal_add_js
(
   
'$(document).ready(function(){
         $("body").width();
     });'
,
   
'inline'
  
);
?>

thanks.

Comments

Use $.get() or $.ajax()

Sounds like you're going to need to use an Ajax call to send the info back to the server. Take a look at http://docs.jquery.com/Ajax for the jQuery docs on this. The Nodeorder project uses $.ajax() to sends back some info to the server, so you can see how it's done there.

Marc

-------
http://www.funnymonkey.com
Tools for Teachers

Marc
-------
http://www.funnymonkey.com
Click. Connect. Learn.

nobody click here