NYCPHP Meetup

[nycphp-talk] Passing JAVASCRIPT variables to PHP

tedd tedd at sperling.com
Mon Mar 31 18:30:56 EDT 2008


At 9:32 AM -0400 3/31/08, Brian D. wrote:
>  >  And don't forget this way:  :-)
>>
>>   var a = 1;
>>   (new Image()).src = '/myscript.php?a='+ a;
>
>I'm going to recommend *against* that. That works, but it's an ugly
>hack, and often when you're trying to do something like this you're
>not addressing a deeper architectural problem.
>
>[snip]

Brian:

Ugly is relative and "hacks" are common -- ever use css?

The solution I provided is simple and works.

The point here -- however -- is that Dan said:

>You either need to submit the JS data to the server as part of a form or
>via an AJAX request.

And, I provided a third way. I think there are probably others.

Cheers,

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list