.show() doesn't work immediately - jQuery
up vote
-2
down vote
favorite
I have a button click function like this :
$("#submitButton").click(function (e)
e.preventDefault();
console.log("let's show my div");
$('#mydiv').show();
//and then doing a lot of front end operations and some ajax calls
)
When I click the submit button, I get the console.log
message immediately. But .show()
method works like 7-8 seconds after that. Can you tell me how I can make .show()
work immediately? Thanks.
EDIT :
My HTML code looks like this :
<div class="main">
<form id="myform" enctype="multipart/form-data" class="contact-forms">
<div class="first-line">
<div class="span3 main-row">
<div class="input">
<input type="text" id="id" name="id" placeholder="insert your ID" maxlength="7" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
</div>
</div>
</div>
<div class="first-line">
<div class="span8 main-row">
<div class="input">
<input type="text" id="name" name="name" placeholder="Your name" />
</div>
</div>
</div>
<div id="mydiv" style="display:none">
<label>
Processing, please wait.
</label>
</div>
</form>
</div>
javascript jquery html
|
show 6 more comments
up vote
-2
down vote
favorite
I have a button click function like this :
$("#submitButton").click(function (e)
e.preventDefault();
console.log("let's show my div");
$('#mydiv').show();
//and then doing a lot of front end operations and some ajax calls
)
When I click the submit button, I get the console.log
message immediately. But .show()
method works like 7-8 seconds after that. Can you tell me how I can make .show()
work immediately? Thanks.
EDIT :
My HTML code looks like this :
<div class="main">
<form id="myform" enctype="multipart/form-data" class="contact-forms">
<div class="first-line">
<div class="span3 main-row">
<div class="input">
<input type="text" id="id" name="id" placeholder="insert your ID" maxlength="7" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
</div>
</div>
</div>
<div class="first-line">
<div class="span8 main-row">
<div class="input">
<input type="text" id="name" name="name" placeholder="Your name" />
</div>
</div>
</div>
<div id="mydiv" style="display:none">
<label>
Processing, please wait.
</label>
</div>
</form>
</div>
javascript jquery html
1
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
2
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
2
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02
|
show 6 more comments
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I have a button click function like this :
$("#submitButton").click(function (e)
e.preventDefault();
console.log("let's show my div");
$('#mydiv').show();
//and then doing a lot of front end operations and some ajax calls
)
When I click the submit button, I get the console.log
message immediately. But .show()
method works like 7-8 seconds after that. Can you tell me how I can make .show()
work immediately? Thanks.
EDIT :
My HTML code looks like this :
<div class="main">
<form id="myform" enctype="multipart/form-data" class="contact-forms">
<div class="first-line">
<div class="span3 main-row">
<div class="input">
<input type="text" id="id" name="id" placeholder="insert your ID" maxlength="7" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
</div>
</div>
</div>
<div class="first-line">
<div class="span8 main-row">
<div class="input">
<input type="text" id="name" name="name" placeholder="Your name" />
</div>
</div>
</div>
<div id="mydiv" style="display:none">
<label>
Processing, please wait.
</label>
</div>
</form>
</div>
javascript jquery html
I have a button click function like this :
$("#submitButton").click(function (e)
e.preventDefault();
console.log("let's show my div");
$('#mydiv').show();
//and then doing a lot of front end operations and some ajax calls
)
When I click the submit button, I get the console.log
message immediately. But .show()
method works like 7-8 seconds after that. Can you tell me how I can make .show()
work immediately? Thanks.
EDIT :
My HTML code looks like this :
<div class="main">
<form id="myform" enctype="multipart/form-data" class="contact-forms">
<div class="first-line">
<div class="span3 main-row">
<div class="input">
<input type="text" id="id" name="id" placeholder="insert your ID" maxlength="7" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
</div>
</div>
</div>
<div class="first-line">
<div class="span8 main-row">
<div class="input">
<input type="text" id="name" name="name" placeholder="Your name" />
</div>
</div>
</div>
<div id="mydiv" style="display:none">
<label>
Processing, please wait.
</label>
</div>
</form>
</div>
javascript jquery html
javascript jquery html
edited Nov 11 at 8:58
asked Nov 11 at 8:45
jason
1,5572169122
1,5572169122
1
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
2
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
2
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02
|
show 6 more comments
1
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
2
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
2
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02
1
1
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
2
2
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
2
2
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02
|
show 6 more comments
1 Answer
1
active
oldest
votes
up vote
-1
down vote
This is example of showing the div , you should hide your div with display none not hidden class , if you use hidden class just remove class to show your div
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
This is example of showing the div , you should hide your div with display none not hidden class , if you use hidden class just remove class to show your div
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
add a comment |
up vote
-1
down vote
This is example of showing the div , you should hide your div with display none not hidden class , if you use hidden class just remove class to show your div
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
add a comment |
up vote
-1
down vote
up vote
-1
down vote
This is example of showing the div , you should hide your div with display none not hidden class , if you use hidden class just remove class to show your div
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
This is example of showing the div , you should hide your div with display none not hidden class , if you use hidden class just remove class to show your div
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
function ShowDiv()
$("#mydiv").show();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mydiv" style='display:none;'>Hello</div>
<button onclick="ShowDiv()"> ShowMe</button>
answered Nov 11 at 8:58
shaghayegh sheykholeslami
1847
1847
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
add a comment |
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
please check this link,Are you sure javascript code in end of body element: jsfiddle.net/Luo06943
– Morteza Fathnia
Nov 11 at 10:29
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
@MortezaFathnia what do you mean?!
– shaghayegh sheykholeslami
Nov 11 at 11:01
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
script tag placed before end of body tag. <body><script></script></body>
– Morteza Fathnia
Nov 11 at 11:41
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
@MortezaFathnia This is not important here ! The problem isn't place of script. In addition when you use code snippet in here and you use jquery it's automatically inserted in your code.
– shaghayegh sheykholeslami
Nov 11 at 11:50
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
do you test the link? I don't find out your meant?!
– Morteza Fathnia
Nov 11 at 11:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247118%2fshow-doesnt-work-immediately-jquery%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What's happening during those 7-8 seconds? Are there CPU-intensive operations?
– CertainPerformance
Nov 11 at 8:47
Can you provide HTML code or create a Fiddle?
– Tân Nguyễn
Nov 11 at 8:48
@CertainPerformance Mostly trying to validate data coming from user and 4-5 AJAX calls.
– jason
Nov 11 at 8:48
2
Given what you've said about it, the code you show should just work with no delay. Since you have a delay, the issue is related to code you haven't shown. In order to troubleshoot this, we're going to need to see a working example.
– Ouroborus
Nov 11 at 8:59
2
The JS + HTML posted in the question does not result in the problem you describe. We do indeed need a Minimal, Complete, and Verifiable example
– CertainPerformance
Nov 11 at 9:02