Forum Stats

  • 3,826,780 Users
  • 2,260,707 Discussions
  • 7,897,072 Comments

Discussions

how to show a loading message

user575089
user575089 Member Posts: 466
edited Mar 31, 2017 11:10AM in Java Programming

I have a submit link with this javascript to submit the  jsp webpage

<a href="#" onclick="javascript:confirmSubmit(contextPath);"

after submit , controller takes lot of time to process and redirects to a list page.

I want

(1) when use click this submit link , this link to disable to avoid double clicking

(2) showing a message "System is processing your request . Please wait"

What changes I should be doing in my code to achieve this goal ?

Please suggest

Answers

  • rpc1
    rpc1 Member Posts: 1,503
    edited Mar 2, 2017 2:51AM

    I solve this problem using Ajax query,

    you could make async request to controller and wait for response, and only after getting response redirects to required page,

  • user575089
    user575089 Member Posts: 466
    edited Mar 2, 2017 5:30AM

    @rpc1

    >>>wait for response, and only after getting response

    What response I'd receive if the page is submitted and redirects to a new page ?

    In Ajax success

    <span class="pln" style="color: #303336;">success</span><span class="pun" style="color: #303336;">:</span><span class="pln" style="color: #303336;"> </span><span class="kwd" style="color: #101094;">function</span><span class="pun" style="color: #303336;">()</span><span class="pln" style="color: #303336;"> </span><span class="pun" style="color: #303336;">{</span><span class="pln" style="color: #303336;"><br/>   </span><span class="com" style="color: #858c93;">// AJAX request finished</span><span class="pln" style="color: #303336;"><br/> </span><span class="pln" style="color: #303336;"><br/></span><span class="pun" style="color: #303336;">}</span>

    we are moving to a  new page with target = _self ..shall we receive success here ?

  • morgalr
    morgalr Member Posts: 457
    edited Mar 14, 2017 3:51PM

    Do your #1 and #2 before you submit the link.

  • Vinod Kumar Kashyap
    Vinod Kumar Kashyap Member Posts: 38
    edited Mar 31, 2017 11:10AM

    create id for <a> element

    <a id="confirm" href="#" onclick="javascript:confirmSubmit(contextPath);">Click Here</a>

    Simple use this in confrimSubmit() method.

    $('#confirm').prop('onclick',null).off('click');
This discussion has been closed.