Send request to the server but don’t necessarily refresh

I have a general question about the feasiblity of this scenario.

I would like to write some javascript to poll my server from my web page.

Basicly i would like to make a request to the server as you would with a submit button. but i only want the page to refresh if  logic that resides on the server indicates that it is approprate to do so.

I have no solid constraints on how to do this and any suggestions would fall on gracious ears.
want More background?

I have a page with a list of tasks i want to check the server for new tasks say every 15 seconds but i dont want the page always refreshing.

CodeMachineAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrmcfeelyCommented:
If have the luxury of making it an "IE only" web page, you could leverage the MSXML object to make synchronous HTTP requests through jscript (without performing any page navigations).

Check out this site, which has an example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/dom_howdoi_21id.asp

Once the content returns, you can parse through it and see if there's a new task... if you make your page with the list of tasks return a well-formed XML document, this solution becomes even easier!


Another option would be to load the tasks page into a hidden IFRAME on the main page, and then parse through the IFRAME's contents using the innerHTML property.  This would effectively keep the main page from refreshing.  There are a couple caveats, though... one, you'd have to write some code to detect when the content in the IFRAME has fully loaded... two, you're subject to cross-domain scripting restrictions (meaning that the innerHTML property is unavailable to you if the page being loaded into the IFRAME is not in the same exact domain as the main page).


These suggestions are admittedly somewhat vague, but they're a couple ideas to get your mind moving.  Let me know if you'd like me to elaborate more on either one of these suggestions.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahosangFinance Systems DeveloperCommented:
A solution is to create new <script> tag and set the source to your server-side page. Then in that logic, if the update is needed, then make the server page send a script that says:
location.reload(true);

So it would be like:
<script>
setTimeout("checkIt()", 15000);
function checkIt() {
  var script=document.createElement("script");
  script.src="checkpage.jsp";
  script.id="checker";
  if (document.getElementById("checker") {
    document.removeChild(document.getElementById("checker"));
  }
  document.getElementsByTagName("head")[0].appendChild(script);
}
</script>
0
devicCommented:
sumit target on hidden iframe.
hidden iframe has event onload.
onload read what send the server.
if server want reload all the page, reload it.
0
CodeMachineAuthor Commented:
Hey thatnks for all yer comments you guys... I sure appreciate it. Dunno who to give th points to. I will have to see what i am gonna implement... Getting to it.

I will let you know
0
CodeMachineAuthor Commented:
Thanks once again to all. Ah the nuances of web programming.

After some research the iframe should provide the functionality i require... with a little work i should have a solution without to much hassle:)

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.