there is any way to use javascript in PHP page that i call with AJAX?
i want to build a function that have a source of design. there is 2 places that i need to use this design. one in the PHP page that i call with the AJAX. and one in JavaScript source. i try to think how could i use the same source of the design in these different functions (one in PHP, and enother with JS)
if someone have an another idia how to do this, it can be greate.
this is my full ajax source:
function ajax(divName, url, generalInfo, info, type) {
var xhr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
var params = "generalInfo="+generalInfo+"&"+infoToTxt(info)+"&divName="+divName;
xhr.open("POST",url,true);
xhr.onreadystatechange = function() {
if( this.readyState == 4 && this.status == 200) {
document.getElementById(divName).innerHTML = this.responseText;
}
};
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);
return false;
}
this is the PHP page that i call with AJAX:
<?php
echo "<div id='a'> aabbb </div>";
?>
<script language=javascript>
document.getElementById("a").innerHTML = "sss";
</script>