.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>









share|improve this question




















  • 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















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>









share|improve this question




















  • 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













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>









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












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>








share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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>








share|improve this answer





















  • 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















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>








share|improve this answer





















  • 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













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>








share|improve this answer












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>






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Bressuire

Vorschmack

Quarantine