Javascript not working on ajax loaded page?
-
i have a page of the form <script src="script.js" .. /> <script src="ajax.js" .. /> <select...><option....></select> <div> //loaded from file.php by getElement() </div> //script.js function fun() { ... } //ajax.js function getXMLHTTP() { //function to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getElement(strURL,divElement) { document.getElementById(divElement).in… var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById(divElement).i… } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } //file.php -- loaded page //some text here <script> fun(); </script> //some text here the main problem that i am facing is i have a function call on the ajax loaded page . None of the other site tell how to handle this situation, they only give scripts for parsing the loaded file for script tags and adding to head.. Can someone please help me out as soon as possible (without jQuery)....
-
Answer:
Very confusing question however I guess you have something to do with //file.php -- loaded page This part has an included script which will be executed whenever this script gives output (prints page). It is because you are calling a function inside script tag. May be you could explain little more that what you want to do? and what is the behavior and how its different than requirement etc =)
george at Yahoo! Answers Visit the source
Related Q & A:
- How to pass multiple parameters in a single Ajax function?Best solution by stackoverflow.com
- What is the simplest ajax upload plugin or script to be used with wordpress?Best solution by WordPress
- How to use ajax with autocomplete in jquery?Best solution by Stack Overflow
- Why is Javascript called Javascript, if it has nothing to do with Java?Best solution by Stack Overflow
- When I click on the YIM icon at Yahoo.com, I am sent to the download page, instead of YIM already loaded. Why?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.