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

xamox - May 18, 2007 - 23:46

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.

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

marcp - May 19, 2007 - 02:47

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

 
 

Drupal is a registered trademark of Dries Buytaert.