Solved

Calling javascript function after server-side code completed

Posted on 2010-09-17
5
250 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: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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query in AngularJS 8 53
Consume a webservice via VB in Visual Studio 2015 3 22
Glitching Slide Show 19 28
Need to find a web event on the IIS server 4 11
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

730 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