Grow your CSS skills. Land your dream job.

Javascript to PHP

  • # May 29, 2009 at 9:24 am

    Hi, I need to send this to a php file without the current page being redirected to the php file. Can you do this?
    document.getElementById("box").value

    so at the moment that should equal ‘hello’ i would like to pass it to the php file as ‘hello’ which the php can treat as a variable.

    Many Thanks

    # May 29, 2009 at 10:43 am

    What you need to employ is the much-hyped AJAX. Since the process of setting up an AJAX connection is different for different browsers and IMHO adds quite a bit of unnecessary markup within the page itself, I would recommend using a JavaScript framework to accomplish this.

    There are plenty of tutorials out there for basic AJAX communication, but here is a quick one: http://www.w3schools.com/Ajax/ajax_intro.asp.

    Whether you use an HTTP GET or POST request, the parameter you pass will be available in php with $_REQUEST, so I think that will help you out.

    # June 12, 2009 at 6:47 am
    "akeenlabs" wrote:
    What you need to employ is the much-hyped AJAX. Since the process of setting up an AJAX connection is different for different browsers and IMHO adds quite a bit of unnecessary markup within the page itself, I would recommend using a JavaScript framework to accomplish this.

    There are plenty of tutorials out there for basic AJAX communication, but here is a quick one: http://www.w3schools.com/Ajax/ajax_intro.asp.

    Whether you use an HTTP GET or POST request, the parameter you pass will be available in php with $_REQUEST, so I think that will help you out.

    Also take a look at jquery or mootools…. writing ajax in just javascript can be painful

    # June 13, 2009 at 11:39 am

    … and ofcourse don’t forget to test your thing with JavaScipt disabled aswell.

    The bare function of the thing should never depend on JavaScript alone, one should be able to perform the core functionality also without JavaScript IMO.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".