DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Call JS function after AJAX

  1. #1
    Join Date
    Apr 2009

    Red face Call JS function after AJAX

    I've come across the common problem within AJAX and I can't call a function already on the page that AJAX has dumped another page into. I've tried everything and asked all around the internet with little helpful supply. Other peoples scripts don't work for mine and I couldn't get anything working with eval().

    Here's 2 pages:
    HTML Code:
    <script type="text/javascript">
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    	try {
    		xmlhttp = new XMLHttpRequest();
    	} catch (e) {
    if (!xmlhttp && window.createRequest) {
    	try {
    		xmlhttp = window.createRequest();
    	} catch (e) {
    function loadajax(){"GET", "ajax.php",true);
     xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
      document.getElementById("show").innerHTML = xmlhttp.responseText;
    <a href="javascript:loadajax();">Load AJAX Page</a><br />
    <div id="show">AJAX will go here</div>
    HTML Code:
    <script type="text/javascript">
    function test(){
    	alert("This doesn't work!");
    <a href="javascript:test();">Click Me</a>
    The link doesn't show the alert like it's meant to.
    Any help really would be appreciated,

  2. #2
    Join Date
    May 2009
    I've gotten round this limitation by writing a response to a hidden IFrame.
    The response contains any JavaScript function calls needed, but must be preceeded by a parent reference.

Similar Threads

  1. using an AJAX function to return a value
    By k285715 in forum AJAX
    Replies: 0
    Last Post: 06-18-2007, 11:06 AM
  2. Thanks!!! Re: call c/c++ function from VB
    By Chris in forum VB Classic
    Replies: 1
    Last Post: 08-08-2002, 11:02 AM
  3. AnimateWindow API
    By Tim Manos in forum VB Classic
    Replies: 4
    Last Post: 10-19-2001, 06:06 AM
  4. Replies: 2
    Last Post: 06-05-2001, 01:55 PM
  5. Re: Dll function call problem - Same problem
    By Fabian in forum VB Classic
    Replies: 7
    Last Post: 06-28-2000, 12:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center