SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simpliest way to send data to PHP script from Javascript?

    Hello guys,

    I wonder, what is the simpliest way to send data to PHP script from Javascript? For example, user clicks some image and JS runs some PHP script in background (so browser keeps loaded page) which makes few MySQL queries etc.

  2. #2
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you're looking for has been one of the biggest buzz words over the past two years... Ajax.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  3. #3
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lkagan View Post
    What you're looking for has been one of the biggest buzz words over the past two years... Ajax.
    Yes, I know it's kind of Ajax. What I ask is what is the simpliest way to do it.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <img src="script.php?data=stuff">
    That easy.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    HTML Code:
    <img src="script.php?data=stuff">
    That easy.
    Thanks. Looks easy.

    But is this a way to call this from JS?

    Or do I need to insert this into some DIV element with innerHTML or do something else to make it work?

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    create an image element, then set the source.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    create an image element, then set the source.
    Thanks. Works like a charm.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •