Jump to content

Archived

This topic is now archived and is closed to further replies.

amalosoul

PHP & Javascript

Recommended Posts

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.