[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Calling javascript function after server-side code completed

Posted on 2010-09-17
5
Medium Priority
?
253 Views
Last Modified: 2012-05-10
Experts,

I would like to show a DIV element after the server-side code has completed.  Therefore, when a user presses submit and the server-side code executes, at the bottom of the code I would like to run the client-script block, passing a string parameter which will be displayed in the DIV.

Should I consider using the icallback handler?
0
Comment
Question by:nickmarshall
[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
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33699837
make sure that
1) div is hidden before making ajax call,
<div id="divId1" style="display:none"></div>
2) in the call back handler, you will get the response, put that response in the div and make that div visible
document.getElementById("divId1").innerHTML = ajax Response;

0
 
LVL 1

Author Comment

by:nickmarshall
ID: 33699869
Hi,

Thanks for the info.  How do I implement the call back handler, and does a callback always occur after the server-side code completes?
0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 33699880
check this example
http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp

Yes, if the readystate is 4, that means the client is ready with server response
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 33699969
Should I add the callback function highlighted here in the head section, or should this be registered in the on_load with the scriptmanager?
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33699980
Callback handler is registered when the ajax call is made using the onreadystatechange, see this example
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_database
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

656 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