You cannot do this because PHP outputs the code before JavaScript . There are many alternative ways to do this:
if outputEl is the identifier of the div element:
1- Without jQuery / JavaScript
<div id="outputEl"><?php include "./change/ud1.php";?></div>
2- Use jQuery load function
$("#outputEl").load('./change/ud1.php');
3- With JavaScript function
window.onload = function() { if (XMLHttpRequest) var x = new XMLHttpRequest(); else var x = new ActiveXObject("Microsoft.XMLHTTP"); x.open("GET", "./change/ud1.php", true); x.send(); x.onreadystatechange = function() { if (x.readyState == 4) { if (x.status == 200) outputEl.innerHTML = x.responseText; else outputEl.innerHTML = "Error loading document"; } } }
Govind samrow
source share