Jump to content

client/server order of operation


vurentjie

Recommended Posts

hi,

 

i am currently developing a member/user's section of a site,

 

a lot of the functionality that i use for speeding up processes involves passing php vars to javascript and vice-versa (although sending javascript back to php is slightly different oweing to the client/server side order of operations);

 

one of the measures i have had to take is making the site work without javascripting as well, which means checking if javascript is enabled or not and then running the relevant php option.

 

at the moment i what i do is this,

 

i run a javascript onload function that changes the value of a hidden input field that i use where neccessary;

then i do a check with php to see whether the value has been changed or not, and thus establish whether javascript is enabled or not;

 

the reason that i am doing this is that i realized it is the only way I could get a javascript variable value into php -

 

while it is relatively simple to pass php to javascript;

 

doing something like the following

 

<?php
$var = "<script language='javascript'> document.writeln(\"hello\"); </script>";

echo $var; this will output "hello"
echo strlen($var); but this will output "69" -guess why? and not the supposed "5"
?>

 

this would've been the ideal way to build a javascript enabled check, but unfortunately i could not get any proper feedback, and is where i learnt a bit more about client/server side order of operations;

 

i was just wandering if there has ever been any strange hacks to get this working, more a curiosity question than anything else,

 

 

later

vurentjie

 

 

 

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.