/    Sign up×
Community /Pin to ProfileBookmark

PHP/Javascript Intercommunication

I don’t think this is possible, but does anyone know of a way to have some type of communication between Javascript and PHP code, be it by passing variables between the two or being able to call PHP code from Javascript? Currently the only mechanism I can come up with to have my Javascript code communicate with my PHP code is by using cookies.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 23.2005 — Hi!

It depends on the desired direction of the communication. If you want js to digest the values of PHP variables, you can have them parsed as js variables. For the other direction (from js to PHP) you would have to transfer the js variables' values to the server by submitting a form.

Cheers - Pit
Copy linkTweet thisAlerts:
@mdouetauthorFeb 23.2005 — That's what I thought, I guess using cookies for intercommunication is my best bet then.

Thanks Pitt.
Copy linkTweet thisAlerts:
@PittimannFeb 23.2005 — Hi!

You're welcome. By the way: the variant PHP to js is very easy to accomplish. Maybe for that part you should consider working without cookies.

Cheers - Pit
Copy linkTweet thisAlerts:
@mdouetauthorFeb 23.2005 — Yes, for PHP to JS I pass PHP info via JS parameters, but for JS to PHP I use cookies to pass back JS info to PHP.
Copy linkTweet thisAlerts:
@JonaFeb 23.2005 — [font=trebuchet ms]You can send XML requests to PHP via the XMLHttpRequest method. [url=http://www.xml.com/pub/a/2005/02/09/xml-http-request.html]Read more[/url].[/font]
Copy linkTweet thisAlerts:
@VladdyFeb 24.2005 — http://www.webdeveloper.com/forum/showthread.php?s=&threadid=5810

while sample is in ASP - principle applies to any server side language.
×

Success!

Help @mdouet spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...