Solved

Calling javascript function after server-side code completed

Posted on 2010-09-17
5
248 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
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
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:
gurvinder372 earned 500 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:gurvinder372
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now