Saturday, 15 September 2018

Form submit is not happening in google chrome Intermittently

I have a webpage which contains iFrame. This webpage auto-submits a form to third party url which loads the content in iFrame. I am currently doing the auto-submit of the form on document.ready() through jQuery and it looks like chrome is not submitting this form intermittently.

Below is the sample html in my webpage.

<form id="form_init" target="myFrame" action="https://somethirdpartyurl.com/req.jsp?queryParam=value" method="post" class=" edit accessAid">
    <input name="_cs" id="_cs2" value="blah" type="hidden">
    <input name="cs" id="cs2" value="blah" type="hidden">
    <input type="hidden" name="howdy" value="oneMoreBlah">
    <input type="hidden" name="myUrl" value="http://localhost:8000/myapp?_eventId=processing&amp;sessionId=123">
    <input type="hidden" name="MD" value="1234567891234567">
    <div id="submit_button">
        <p>Attention: This form can't be displayed because JavaScript is disabled in your browser.</p>
        <p class="buttons">
            <span class="buttonAsLink">
                <input type="submit" name="" class="button autoSubmit" value="Click here to continue">
            </span>
        </p>
    </div>
</form>

<iframe name="myFrame" id="myFrame" width="625px" height="480px" frameborder="0" marginheight="0" scrolling="auto" src="https://www.mywebsite.com/grey_spacer.gif"></iframe>

<script src="http://www.localhost:8000/myapp/webstatic/js/loadFrame.js" type="text/javascript"></script>

Below is the snippet for loadFrame.js file.

$(document).ready(function() {
    $("#submit_button").length && ($("#submit_button").hide(), $("#submit_button input").hasClass("autoSubmit" && $("#submit_button input")[0].form.submit());
});

Note that all the conditions before $("submit_button input")[0].form.submit() command are success.I have confirmed it through console logs.

The problem I am facing now is, chrome is not submitting the above form intermittently. This issue is not present in other browsers like FireFox and Safari.

One observation is that, when I open developer tools and checking the disable cache option, most of the times form is not getting submitted. If I uncheck the option, mostly the form is getting submitted. (This is true for majority of the times, not all)

One more thing is, when I manually execute the same command $("submit_button input")[0].form.submit() in console, chrome is submitting the form and everything working fine.

Can someone tell me why this issue is coming or at least an alternative solution for this issue? I am hoping that all the required information is provided. Let me know, if you need any other details.



from Form submit is not happening in google chrome Intermittently

No comments:

Post a Comment