Php And Js In Multi-page Environment
I apologize in advance for this being a bit long. I've been trying to figure this out for a while without success, so I wanted to post most of my code so the amazing people helpin
Solution 1:
The big problem is the HTML content you're loading into the DOM does not process the JavaScript files you've included. So, you should use jQuery's .load()
to properly load the page behind your AJAX call. This will load the included JavaScript files.
This entire block:
functionshowUser(str) {
if (str !==".PM") {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=newXMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
becomes:
functionshowUser(str) {
if (str !==".PM") {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
}
$("#txtHint").load( "getuser.php?q="+str );
}
Post a Comment for "Php And Js In Multi-page Environment"