Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

reload the page without refreshing???

Posted on 2011-02-25
4
Medium Priority
?
275 Views
Last Modified: 2012-05-11
Hi all,

I've got some javascript on the $(document).ready(function(){  ... so what page ls loaded.

I have a variable which is changed at runtime ... now depending on the value of this variable some div's are loaded or not.

How can I make the call the $(document).ready(function(){ at runtime please ... or if it cannot be done... how can I do this please?

thanks


0
Comment
Question by:error77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 34978205
if you are loading the div with an ajax response, you can then use the callback handler of that ajax call
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 34978216
<<How can I make the call the $(document).ready(function(){ at runtime please ... or if it cannot be done... how can I do this please?>>
document.ready is called by itself. Its basically a event handler which is invoked when the page is loaded.

But why do you want to call this document.ready at run-time at first place?
0
 

Author Comment

by:error77
ID: 34978236
Ref: But why do you want to call this document.ready at run-time at first place? ... I have some code that runs on $(document).ready(function(){ and I basically want to run it again because I'm changing things at runtime

For example, I have:

IF (thisvariable==0) {
  $('#myDiv1').hide();
} else {
    $('#myDiv1').show();
}

Now... when I change "thisvariable" value at runtime, I need to re-run the code so changes are made acordingly...know what I mean?

Thanks

0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 34978359
you can encapsulate/refactor the code inside into a method and call that method whenever you want to

$(document).ready(function(){

 ///what ever is here put that in a method, say docReady()
});

function docReady()
{
 //put all document ready code here
}


now you can call docReady whenever you want to
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question