Jump to content


Photo

PHP & Javascript


  • Please log in to reply
1 reply to this topic

#1 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 29 September 2006 - 01:28 PM

I have three files in which I want to include a php file using javascript:
here they are
1.
<?php
$html = '<b>This content came from our Ajax Engine</b>';?>
div = document.getElementById('contentdiv');
div.innerHTML = '<?php echo $html; ?>';
// this is the php file

2.
url = "http:/localhost/page1.php"; //url=document.location.href
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(, xend);
function ajax_do (url) {// Does URL begin with http?
if (url.substring(, 4) != 'http') {url = base_url + url;}// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url;// Append JS element (therefore executing the 'AJAX' call)
document.body.appendChild (jsel);}
//this is the engine.js



#2 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 29 September 2006 - 01:33 PM

For some reason that I don't understand the text in the php page is not included. Can you help me?
Thank you in anticipation!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users