Way to javascript onclick send information, but user doesnt see popup

Discussion in 'JavaScript' started by MarcL, Mar 29, 2011.

  1. #1
    Is there a way to do a javascript call such as

    window.open

    except just send the information in the background? I need to send information to a company if they press onclick but dont want a popup to annoy the user every time they click a radio button. Notice this info doesnt need to be stored into a database, just sent to a url.

    Marc
     
    MarcL, Mar 29, 2011 IP
  2. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use AJAX for this requirement
     
    vinoth.t, Mar 29, 2011 IP
  3. MarcL

    MarcL Notable Member

    Messages:
    4,265
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #3
    You know of a way? Like maybe post the values to thispage.php and then that page would open a frame to http://www.company.com/record.php?name=$name&email=$email
    ??

    But how would you make a ajax post even hidden? I need to take variables and pretty much have the server send the information.

    Marc
     
    MarcL, Mar 30, 2011 IP
  4. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    You can have a hidden image and change its src to the page that you want requested.
    
    <img id="hiddenimg" style="visibility: hidden;" />
    <script type="text/javascript">
    ....
    document.getElementById("hiddenimg").src = "http://www.website.com/?val1=123&val2=456";
    ....
    </script>
    
    Code (markup):
     
    camjohnson95, Mar 30, 2011 IP
  5. MarcL

    MarcL Notable Member

    Messages:
    4,265
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #5
    How would I onclick this?

    Would I onclick to a post ajax function which then opened up a post.php which then had the hidden image? Or is there a way to onclick directly to that?

    That is a great idea if it really will submit so the other website gets the information.

    Marc
     
    MarcL, Mar 30, 2011 IP