dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: loaded page can not run javascript :-(

  1. #1
    Join Date
    Oct 2008
    Posts
    3

    Question loaded page can not run javascript :-(

    Hi,

    i have a simple ajax script which load pages into divs. this works perfectly.
    my problem is that loaded pages should run some javascript scripts and once loaded into divs, they do not.

    where could be the problem ?
    here is an example of loaded page:
    Code:
    <html>
    <body>
    <script>
    	alert("test");
    	Remove_js_css_file("modules/tool/tool.css", "css");
    </script>	
    
    <link rel='stylesheet' type='text/css' href='modules/tool/tool.css' media='screen' />
    	
    <div class='local_breadcrumb'>
    	<div class='breadcrumb_txt'>test of local tool.css which does not work !</div>
    </div>
    	
    <div class='helo'>test
    </div>
    
    </body>
    </html>

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Welcome to DevX

    Does the javascript cause errors or just not do anything at all?

  3. #3
    Join Date
    Oct 2008
    Posts
    3
    in fact, it does not do anything at all.
    for example, i just placed a simple alert("test"); and nothing happened.
    neither error nor message.

  4. #4
    Join Date
    Oct 2008
    Posts
    3
    still no idea ?

  5. #5
    Join Date
    Mar 2007
    Location
    Bangalore, India
    Posts
    247
    How do you add the AJAX obtained content into your page? Using innerHTML or DOM manipulation? I believe it should work if you use innerHTML. To load an external script (.js file), you can also dynamically create a "script" element (DOM; createElement), add the src attribute and insert into the document tree somewhere.

    Code:
    function myajaxcallback()
    {
      // Do whatever
      var scriptsource = "/srcipts/source.js";
      var scel = document.createElement("script");
      scel.addAttribute("src", scriptsource);
      document.body.addendChild(scel);
    }

  6. #6
    Join Date
    Oct 2008
    Posts
    1
    Hi,

    I too have same problem, server returns response in text format. The response text contains the javascript, entire response code has been added to div element. The javascript with in the response text is not at all triggerd/called.

    Any suggestion are welcome.

    Thanks,

  7. #7
    Join Date
    Oct 2008
    Posts
    3

    Re :

    Hi ,

    i also was having such kind of problem, and what i did was i didnt include the javascript in the response text(results.jsp). Instead , i placed the javascript within <head> element of the page (index.jsp) , in which the response text will be printed. That method worked fine.

    In that way i could be able to have my javascript as a seperate file and import it to the index.jsp.

    Hope this will be useful.. , n by the way im also pretty much new to AJAX development

    i too have an unsolved question regarding CSS support in the updated content, that is , the repsonse text.. if anybody of u knws that pls help me to sort it out..

    Regards
    Sk

Similar Threads

  1. Run a telnet through an ASP page.
    By iKhristosi in forum ASP.NET
    Replies: 1
    Last Post: 08-12-2008, 12:47 PM
  2. Replies: 2
    Last Post: 04-21-2003, 07:12 AM
  3. Replies: 13
    Last Post: 10-03-2001, 04:05 PM
  4. Replies: 0
    Last Post: 02-14-2001, 08:32 AM
  5. Replies: 2
    Last Post: 12-14-2000, 11:46 AM

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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