?
Solved

Calling javascript function after server-side code completed

Posted on 2010-09-17
5
Medium Priority
?
252 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

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'…
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…
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

770 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