473,602 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.XMLHttp Request) // if Mozilla, Safari etc
page_request = new XMLHttpRequest( )
else if (window.ActiveX Object){ // if IE
try {
page_request = new ActiveXObject(" Msxml2.XMLHTTP" )
}
catch (e){
try{
page_request = new ActiveXObject(" Microsoft.XMLHT TP")
}
catch (e){}
}
}
else
return false

page_request.on readystatechang e=function(){
loadpage(page_r equest, containerid)
}
page_request.op en('GET', url, true)
page_request.se nd(null)
}

function loadpage(page_r equest, containerid)
{
if (page_request.r eadyState == 4 && (page_request.s tatus==200 ||
window.location .href.indexOf(" http")==-1))

document.getEle mentById(contai nerid).innerHTM L=page_request. responseText
}

In html page, I used the following line to load a php page:
<script language="JavaS cript" type="text/javascript">
javascript:ajax page('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.ph p");
$mid = new TreeMenu();
$mid->setMenuStructu reFile("treemen u.txt");
$mid->parseStructure ForMenu("Treeme nu");
$mid->newTreeMenu("T reemenu");
$mid->printTreeMenu( "Treemenu") ;
?>

Feb 25 '06 #1
6 3073
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.XMLHttp Request) // if Mozilla, Safari etc
page_request = new XMLHttpRequest( )
else if (window.ActiveX Object){ // if IE
try {
page_request = new ActiveXObject(" Msxml2.XMLHTTP" )
}
catch (e){
try{
page_request = new ActiveXObject(" Microsoft.XMLHT TP")
}
catch (e){}
}
}
else
return false

page_request.on readystatechang e=function(){
loadpage(page_r equest, containerid)
}
page_request.op en('GET', url, true)
page_request.se nd(null)
}

function loadpage(page_r equest, containerid)
{
if (page_request.r eadyState == 4 && (page_request.s tatus==200 ||
window.location .href.indexOf(" http")==-1))

document.getEle mentById(contai nerid).innerHTM L=page_request. responseText
}

In html page, I used the following line to load a php page:
<script language="JavaS cript" type="text/javascript">
javascript:ajax page('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.ph p");
$mid = new TreeMenu();
$mid->setMenuStructu reFile("treemen u.txt");
$mid->parseStructure ForMenu("Treeme nu");
$mid->newTreeMenu("T reemenu");
$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>Mailou t Campaign Profiling</title>

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

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

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

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

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

</html>
Feb 25 '06 #2
In article <44********@new s.rivernet.com. au>, ac***@telpacifi c.com.au
says...
javascript:ajax page('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********@new s.rivernet.com. au>, ac***@telpacifi c.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********@new s.rivernet.com. au>, ac***@telpacifi c.com.au
says...
javascript:ajax page('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********@new s.rivernet.com. au>, ac***@telpacifi c.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="JavaS cript" type="text/javascript">
ajaxpage('treem enu.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.XMLHttp Request) // if Mozilla, Safari etc
page_request = new XMLHttpRequest( )
else if (window.ActiveX Object){ // if IE
try {
page_request = new ActiveXObject(" Msxml2.XMLHTTP" )
}
catch (e){
try{
page_request = new ActiveXObject(" Microsoft.XMLHT TP")
}
catch (e){}
}
}
else
return false

page_request.on readystatechang e=function(){
loadpage(page_r equest, containerid)
}
page_request.op en('GET', url, true)
page_request.se nd(null)
}

function loadpage(page_r equest, containerid)
{
if (page_request.r eadyState == 4 && (page_request.s tatus==200 ||
window.location .href.indexOf(" http")==-1))

document.getEle mentById(contai nerid).innerHTM L=page_request. responseText
}

In html page, I used the following line to load a php page:
<script language="JavaS cript" type="text/javascript">
javascript:ajax page('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.ph p");
$mid = new TreeMenu();
$mid->setMenuStructu reFile("treemen u.txt");
$mid->parseStructure ForMenu("Treeme nu");
$mid->newTreeMenu("T reemenu");
$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
2106
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: Sub loadPage(sender As Object, e As System.EventArgs, pageURL as String)
15
10075
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 popup has a DataGrid on it and the page.load function DataBinds as you'd expect. I have Code-Behind in C# to emit a call to a JavaScript function which
6
2359
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. I think there is a window.addEventListener() function but I am not sure which event to listen to. Thank you.
1
5112
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 information to load. Any suggestions on how I might get around that. The articles tab is the tab where the javascript won't load. Thanks so much for any help you might be able to provide: This is what the tabs code looks like: <ul...
5
9205
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. Everything works fine. I've recently been adding "animations" to my web application using Ajax. The animation "Fades" the page in once it is finished loading (without this fading effect the page load is very choppy). My Tab Control requires some...
1
1696
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 the toolbar id. I need to capture the toolbar id and save into the mysql database during the page load.
5
3427
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 from the page load event of the page? I am able to run the function when there is a change in, say, a text box, by adding the following to the page load event: TextBox.Attributes.Add("onChange", "javascript:myfunction()")
4
8399
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 onactivetabindexchanged we have called a method loadtabpanel() which is defined in javascript in same page.the problem is it sometime give the message load tab panel undefined. this error does not come regularly. it comes in usercontrol rendering . i...
2
6934
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 and i am implementing it in my website....
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.