[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Calling javascript function after server-side code completed

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
nickmarshall
Asked:
nickmarshall
  • 3
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
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
 
nickmarshallAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
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
 
nickmarshallAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now