Daniel H
Daniel H

Reputation: 2925

Using HTML post without affecting the current page

I am using the following form to send text messages from our Esendex account:

        <form method="post" action="https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx">

        <P>Username:<br>
            <INPUT name="EsendexUsername" type="text"></P>
        <P>Password:<br>
            <INPUT name="EsendexPassword" type="password"></P>
        <P>Account:<br>
            <INPUT name="EsendexAccount" type="text"></P>
        <P>Recipient:<br>

            <INPUT name="EsendexRecipient" type="text"></P>
        <P>Message:<br>
            <TEXTAREA name="EsendexBody" rows="3" cols="20"></TEXTAREA></P>
        <input type="submit" value="Send">
    </form>

This is working fine, but when I submit the form it automatically goes to the Esendex page. What I need is to be able to post the information to the Esendex page, but leave the current page untouched because it has information like a stopwatch etc which need to carry on running.

Is there any easy way to do this? I don't need any reply from the Esendex website, just send the information to it and that's it.

Thanks for any help

Upvotes: 1

Views: 462

Answers (2)

Paul D. Waite
Paul D. Waite

Reputation: 98796

I think you’re a bit stuck, at least on the client side — JavaScript allows you to make HTTP POST requests, but only to the same domain that your web page is served from, which rules out sending data to Esendex.

You could submit the form to a script on your server, and get the server to send the HTTP POST to Esendex.

Upvotes: 3

Aditya Manohar
Aditya Manohar

Reputation: 2274

You can POST through an <iframe>.

<form action="something" target="iframe_id">

</form>
<iframe id="iframe_id" name="iframe_name" style="display:none;"></iframe>

Please note. This might fail some enterprise security tests.

Your other alternative is use AJAX using jQuery

Upvotes: 5

Related Questions