473,225 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

load in a php page from javascript

Hi,

In a html page, I don't know how to load in a php page from javascript.
I've already defined a <div id="treemenu"> in the html page. The
executed content from the php script is supposed loaded into the
treemenu div. What is the best way to achieve this? I got error where
the treemenu didn't close/open on the treenode, as when I clicked on the
treenode, it said Object not found. But if I don't use ajaxpage()
javascript function, and copy the content of the php script under the
<div id="treemenu"> section, the treemenu works well.

Here is the javascript functions I m using to load a php script:

function ajaxpage(url, containerid)
{
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false

page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid)
{
if (page_request.readyState == 4 && (page_request.status==200 ||
window.location.href.indexOf("http")==-1))

document.getElementById(containerid).innerHTML=pag e_request.responseText
}

In html page, I used the following line to load a php page:
<script language="JavaScript" type="text/javascript">
javascript:ajaxpage('treemenu.php', 'treemenu');
</script>

The following script is treemenu.php:
<?php
include ("lib/PHPLIB.php");
include ("lib/layersmenu-common.inc.php");
include ("lib/treemenu.inc.php");
$mid = new TreeMenu();
$mid->setMenuStructureFile("treemenu.txt");
$mid->parseStructureForMenu("Treemenu");
$mid->newTreeMenu("Treemenu");
$mid->printTreeMenu("Treemenu");
?>

Feb 25 '06 #1
6 3054
acord wrote:
Hi,

In a html page, I don't know how to load in a php page from javascript.
I've already defined a <div id="treemenu"> in the html page. The
executed content from the php script is supposed loaded into the
treemenu div. What is the best way to achieve this? I got error where
the treemenu didn't close/open on the treenode, as when I clicked on the
treenode, it said Object not found. But if I don't use ajaxpage()
javascript function, and copy the content of the php script under the
<div id="treemenu"> section, the treemenu works well.

Here is the javascript functions I m using to load a php script:

function ajaxpage(url, containerid)
{
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false

page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid)
{
if (page_request.readyState == 4 && (page_request.status==200 ||
window.location.href.indexOf("http")==-1))

document.getElementById(containerid).innerHTML=pag e_request.responseText
}

In html page, I used the following line to load a php page:
<script language="JavaScript" type="text/javascript">
javascript:ajaxpage('treemenu.php', 'treemenu');
</script>

The following script is treemenu.php:
<?php
include ("lib/PHPLIB.php");
include ("lib/layersmenu-common.inc.php");
include ("lib/treemenu.inc.php");
$mid = new TreeMenu();
$mid->setMenuStructureFile("treemenu.txt");
$mid->parseStructureForMenu("Treemenu");
$mid->newTreeMenu("Treemenu");
$mid->printTreeMenu("Treemenu");
?>


Hi,

This is the main php script used to initiate the execution:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mailout Campaign Profiling</title>

<link href="css/default.css" rel="stylesheet" type="text/css">

<script src="lib/ajax.js" language="JavaScript"
type="text/javascript"></script>
<base target="contentframe"></base>
</head>
<body>
<table cellpadding="0" cellspacing="0" width="997" align="left">
<tr valign="top">
<!-- START: Tree Menu -->
<td style="background-color:#FFFFFF; border-right:1px
solid #999999;">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></meta>
<link rel="stylesheet" href="layersmenu-demo.css" type="text/css"></link>
<link rel="stylesheet" href="layerstreemenu.css" type="text/css"></link>

<link rel="shortcut icon" href="LOGOS/shortcut_icon_phplm.png"></link>
<title>The PHP Layers Menu System</title>
<script language="JavaScript" type="text/javascript">
<!--
<?php include ("libjs/layersmenu-browser_detection.js"); ?>
// -->
</script>
<script language="JavaScript" type="text/javascript"
src="libjs/layerstreemenu-cookies.js"></script>

<base target="contentframe"></base>
<div id="treemenu">
</div>
</td>
<!-- END: Tree Menu -->
<td>
<base target="contentframe"></base>
<div id="rightContent">
<!-- load in content at the end of this file -->
</div>
</td>
</tr>
</table>
</body>

<script language="JavaScript" type="text/javascript">
javascript:ajaxpage('treemenu.php', 'treemenu');
javascript:ajaxpage('right-content.html', 'rightContent');
</script>

</html>
Feb 25 '06 #2
In article <44********@news.rivernet.com.au>, ac***@telpacific.com.au
says...
javascript:ajaxpage('treemenu.php', 'treemenu');


Why have you got the "javascript:" prefix within your JavaScript?

Considering your PHP always seems to output the same stuff, why not just
include it?

I would have been wise to have included a URL where this code can be
seen in action, especially as you haven't mentioned what the error is.

--

Hywel
http://kibo.org.uk/
Feb 25 '06 #3
In article <44********@news.rivernet.com.au>, ac***@telpacific.com.au
says...
acord wrote:
Hi,

In a html page, I don't know how to load in a php page from javascript.
I've already defined a <div id="treemenu"> in the html page. The
executed content from the php script is supposed loaded into the
treemenu div. What is the best way to achieve this? I got error where
the treemenu didn't close/open on the treenode, as when I clicked on the
treenode, it said Object not found. But if I don't use ajaxpage()
javascript function, and copy the content of the php script under the
<div id="treemenu"> section, the treemenu works well.

Here is the javascript functions I m using to load a php script:


<snipped a load of rather badly written code />

So what? From the code you've posted how are we to determine what your
PHP script outputs?

--

Hywel
http://kibo.org.uk/
Feb 25 '06 #4
Hywel Jenkins wrote:
In article <44********@news.rivernet.com.au>, ac***@telpacific.com.au
says...
javascript:ajaxpage('treemenu.php', 'treemenu');

Why have you got the "javascript:" prefix within your JavaScript?

Considering your PHP always seems to output the same stuff, why not just
include it?

I would have been wise to have included a URL where this code can be
seen in action, especially as you haven't mentioned what the error is.

Hi

I have just removed the "javascript:", but it doesn't make any
difference. How to include php (to put its output) in the div section?

Sorry I m more than happy to show the public URL, there is no public
URL, I m developing this in my private network.

Thanks
A
Feb 25 '06 #5
Hywel Jenkins wrote:
In article <44********@news.rivernet.com.au>, ac***@telpacific.com.au
says...
acord wrote:
Hi,

In a html page, I don't know how to load in a php page from javascript.
I've already defined a <div id="treemenu"> in the html page. The
executed content from the php script is supposed loaded into the
treemenu div. What is the best way to achieve this? I got error where
the treemenu didn't close/open on the treenode, as when I clicked on the
treenode, it said Object not found. But if I don't use ajaxpage()
javascript function, and copy the content of the php script under the
<div id="treemenu"> section, the treemenu works well.

Here is the javascript functions I m using to load a php script:

<snipped a load of rather badly written code />

So what? From the code you've posted how are we to determine what your
PHP script outputs?

It's always difficult (or impossible) to show the output of the php
code, coz the output invoke other javascript libs. I found that if I use
javascript (ajaxpage()) to load the php script into the div treemenu
section, the php code will not call the javascript functions. But if I
put the php codes inside the div treemneu section, the php code invoke
the javascript functions (from the lib), then I can click the tree node
of the menu.

I suspect there is some sequential order when using javascript invoke
the php script in a html file. In my example, I created html script,
then defined a div treemenu, then load the php script at the end of the
html script, eg:

<HTML>
....
<div id="treemenu">
</div>

<script language="JavaScript" type="text/javascript">
ajaxpage('treemenu.php', 'treemenu');
</script>

</HTML>

I created this file with php extention, (eg. test8.php).
I suspect this order is not right. I also tried .html file extention
name, but still not help.

Thanks
A
Feb 25 '06 #6
acord wrote:
Hi,

In a html page, I don't know how to load in a php page from javascript.
I've already defined a <div id="treemenu"> in the html page. The
executed content from the php script is supposed loaded into the
treemenu div. What is the best way to achieve this? I got error where
the treemenu didn't close/open on the treenode, as when I clicked on the
treenode, it said Object not found. But if I don't use ajaxpage()
javascript function, and copy the content of the php script under the
<div id="treemenu"> section, the treemenu works well.

Here is the javascript functions I m using to load a php script:

function ajaxpage(url, containerid)
{
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false

page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid)
{
if (page_request.readyState == 4 && (page_request.status==200 ||
window.location.href.indexOf("http")==-1))

document.getElementById(containerid).innerHTML=pag e_request.responseText
}

In html page, I used the following line to load a php page:
<script language="JavaScript" type="text/javascript">
javascript:ajaxpage('treemenu.php', 'treemenu');
</script>

The following script is treemenu.php:
<?php
include ("lib/PHPLIB.php");
include ("lib/layersmenu-common.inc.php");
include ("lib/treemenu.inc.php");
$mid = new TreeMenu();
$mid->setMenuStructureFile("treemenu.txt");
$mid->parseStructureForMenu("Treemenu");
$mid->newTreeMenu("Treemenu");
$mid->printTreeMenu("Treemenu");
?>

Hi,

I m actually using PHP Layers Menu System 3.2.0.
I tried to change the iframe to div, but I encountered the above problem.

thanks
A
Feb 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shapper | last post by:
Hello, I am working on an ASP.NET/VB web site. I have several links including menu links. Considerer a want to load a page named page.aspx. I can do it using javascript. Or using this code:...
15
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
1
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the...
5
Frinavale
by: Frinavale | last post by:
I have a slight problem with a Tab Control that I've developed for an application. Once sent to the browser it runs via JavaScript. The JavaScript is dynamically generated by my .NET code. ...
1
by: jmohan | last post by:
Hi everyone, I am developing a website using asp.net with C#. And I developed a toolbar using javascript like google and yahoo toolbar which is placed in the browser separately. Toolbar has...
5
by: =?Utf-8?B?TWF0Y29u?= | last post by:
Hello, I have a asp.net 2.0 (vb.net) page, which uses a master page, and there is a javascript function (myfunction) defined in the <headof that master page. Is there a way to run the function...
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.