Re: Javascript/PHP interaction



Brad Everman schrieb:
Suppose I have a bunch of DOM objects (namely images) and want to pass the attributes of these DOM objects to a PHP script. What is the easiest way to accomplish this? Basically, I have a bunch of images that can be manipulated by Javascript and want to determine their final locations after the user is done moving them. For instance, one of the attitbutes might be dd.elements.circle1.h, where h is the height of the image named circle1. This height is set when the page is loaded, but may change as the user manipulates the circle. Would I be better off just writing a bunch of form data then passing this to PHP? I vaguely remember seeing something about manipulating session variables with Javacript.

Thanks for any help.

Communicating between Javascript and the server is best done with an XMLHttpRequest. Essentially, the script makes a call back to the server (probably using POST, in your case, and sending the data manipulated by the user), the server processes it and then returns a response that the script can parse.

Note that even though it's called "XML", the request and response don't need to be formatted as XML, which can save a lot of time if you haven't worked with XML document definitions before.

This is somewhat helpful: http://en.wikipedia.org/wiki/XMLHttpRequest

--
CB
.



Relevant Pages

  • wait for send event
    ... I have a script that deals with a bunch of jpg's at a time. ... But if I lower the amount it will miss some of the images, ... Keep well, Ursus ...
    (comp.databases.filemaker)
  • Re: Creating server based image catalogs with Filemaker?
    ... I send incoming pics through a batchrename (also a filemaker ... I did not send you a script, but some calculation examples. ... Currently it holds over 15,000 images, and more are added ...
    (comp.databases.filemaker)
  • Re: yet another question on file names with spaces?
    ... > I agree, the echo is redudant. ... > know what they are before the script runs - see below. ... > finding whether they are also on the remote machine. ... > images and pdfs which I only want to transfer once. ...
    (comp.unix.shell)
  • Re: change images
    ... Some UA's can't update the display style with script, in which case, ... Style in FF) and you will see that all of the images are there from ... display styles to "none" and then show the container. ... var oldMenuItem; ...
    (comp.lang.javascript)
  • Re: How resource-intensive are these?
    ... > stringing together 8 smaller images. ... > month, because another little script of mine, BattleFishies ... > everything will come crashing down, with smoke coming out of the server ... requests in 1 second for example. ...
    (alt.php)