Re: [PHP] Saving css state in javascript and passing to php via form submit



On 3/30/07, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
Tim wrote:
> > > > > >
>>>>>> I think you want to use sessions for this :)
>>>>> Ok, i can put the data in the session variable, but i can
>>>> only get the
>>>>> "current" state through javascript
>>>>>
>>>>> ie:onsubmit="getstate()"; which would get the id's of the
>>>> blocks that
>>>>> are set to display:block;
>>>>>
>>>>> But in getstate() how do i pass that to php to set that
>>>> session variable?
>>>>
>>>> You could use AJAX to get things from/to PHP, but why should you?
>>>> You can use session within javascript too i believe.
>>> Hmm javascript setting server-side session data??
>>> Sounds weird, but i'll look into it..
>> server-side session data? i never heard of server-side sessions...
>> AFAIK they are send in the HTTP headers from and to the server.
>> Cookies are nearly the same as sessions, i found this article (with
>> examples) that goes about parsing cookies from javascript. So
>> you could also do it with cookies.
>> http://www.javascriptkit.com/javatutors/cookie2.shtml
> Ermmm...
> Isn't $_SESSION a superglobal available only during script execution?
> Yes it sets a session_id in a cookie to which is sent to the server to
> identifie the client, but to my knowledge $_SESSION['my_var'] = 'some_data';
> is stored server side and set only through a server side script...
>
> Now storing data in cookies is client-side, that i agree..
> Am i confused or are you confusing me? :P
>
>>>>>> Tijnema
>>>>>>
>>>>>> ps. Maybe you could also use AJAX instead of submitting forms
>>>>>> the whole time.
>>>>> In the next version of my framework i would like to, i still
>>>>> havent quite understood the whole concept, not enough research
>>>> yet, but yes
>>>>> i'll be doing that next ;) (you know deadlines, can't sit
>>>> and read docs all day etc..
>>>>> Although i'd rather!)
>>>>>
>>>>> ;)
>>>>>
>>>>> Regards,
>>>>>
>>>>> Tim
>>>> Really, it's not that hard to use AJAX. You might want to look at
>>>> www.tizag.com, there it is really easy explained.
>>>> It's nothing more then making new request to scripts inside
>>>> javascript.
>>> Nice tutorial thanks for that, i'll look it up, maybe
>> intergrate it
>>> right away, would really make my day if i could :))
>>>
>>> Regards,
>>>
>>> Tim
>> It's not too hard, but if you already did a lot of work on
>> the form processing, you prefer not to write it all over
>> again i think ;)
>
> Wrote a class to do the form validation, so i could always make a .php that
> runs the form data through the validator and sends back the response.. In
> xml i think it has to be?

the response doesn't have to be in any particular form ... ofcourse the X in AJAX
refers to XML but it's not obligatory .... in the end your just spitting out
a big long string and your clientside code can do with it whatever it wants.

personally I prefer JSON formatted data, for which there are even a couple of
functions available in newer versions of php (otherwise you can find code on the net
easily enough to handle JSON data creation/parsing):

http://php.net/json

I prefer not to do a lot of processing in Javascript, what i usually
do is send plain HTML and directly output it inside a <div>

Tijnema

>
> Regards,
>
> Tim
>


.



Relevant Pages

  • Re: Attempt to de-mystify AJAX
    ... >> poster said "I don't want to hodl tons of data in a hidden frame, ... I never use cookies so a user ... How do you "break" the session key? ... > as needed back to the server. ...
    (comp.databases.pick)
  • Re: Attempt to de-mystify AJAX
    ... "Hyperlinks" always open a new browser window. ... What I meant is that the server, from its state tables, can easily determine ... >>> around cookies and JS, but it seems to be tough. ... >>> 1) use cookies to maintain the session key and hope that the expiration ...
    (comp.databases.pick)
  • Re: NotificationSampleWebDav-Monitor OWA Inbox
    ... when you send your authentication cookies along a request in the ... the response should also contain new cookies. ... Can you guide me how can I update the cookie with new response. ... Warning: Exiting Action with an exception: The remote server returned ...
    (microsoft.public.exchange.applications)
  • Re: PHP/MySQL oldies
    ... > secure when you leave it lying around in a PHP file on your web server? ... safe mode is always enabled, ... is using cookies ...
    (uk.net.web.authoring)
  • Re: Cross-domain cookie updating ?
    ... It's not strictly a PHP question, but something that PHP guys would know the answer to. ... Let's say we have a HTML page from domain example.com, and that HTML page makes a request to example.com to return a JavaScript file. ... If the file being returned has updated cookie information in the response header, then I imagine the cookies for example.com get updated. ... What if the JS file it's requesting is actually to a different unrelated domain server that's going to return a JavaScript file with updated cookies in the response header. ...
    (comp.lang.php)