开发者

Trouble with an auto-submitting form

I'm working on an intermediary form that will gather some data from the user submitted form, and then re-build the form and send it to our authorizer in the appropriate format. Everything is working fine except that I cannot get it to submit this secondary form automatically. I have read several other posts on SO regarding this issue, but they all seem to be requiring a trigger to then submit the form, which mine does not. I simply require it to submit, and my jQuery seems to be taking a nap.

...data gathered here...

echo "<html><head></head><body>";

echo "<form id='forwarderForm' method='post' action='https://www.beanstream.com/scripts/process_transaction.asp'>";

    //rebuild the form to send to beanstream
    $keys = array_keys($_POST);
    for($i = 0; $i < count($_POST); $i++) {
        $currentKey = $keys[$i];
        $currentPost = $_POST[$currentKey];
        echo "<INPUT TYPE='hidden' NAME='" .$currentKey. "' VALUE='" .$currentPost. "'>";
    }
echo "</form>

<scr开发者_如何学JAVAipt type='text/javascript'>

$('#forwarderForm').submit();

</script></body></html>  ";

I have also tried removing the jQuery from the PHP echo, but this does not work either. when using a standard submit button to send the form, everything works fantastic, but I can't get it to submit by itself.

I added the HTML/HEAD/BODY tags later because I was unsure if they mattered for the purposes of a simple form construct/submit, but this did not appear to change anything.

any comments, suggestions and advice is greatly appreciated. I know it's probably something very simple that's eluding me, so your help is appreciated.


You will need to add this in a document.ready clause, like this

<script>
$(document).ready(function () { $('#forwarderForm').submit(); } );
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜