473,808 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to insert content of a html file into a DIV?

4 New Member
Hello, I'm new here and I'm troubling with something.
I'm working on a website which have a treemenu. I've gotten the menu to work alright but I want the DIV which contains the treemenu to have a javascript/ajax which inserts the content of another html file into it. So I don't have to manually edit the code for the menu for each document.

I've put up an Abyss webserver locally here to avoid any issues with the Ajax code.

I've tried using the code found here:
http://www.dhtmlgoodies.com/index.ht...al=ajax-basics

And I basically get an error:

Expand|Select|Wrap|Line Numbers
  1. Line: 41
  2. Char: 1
  3. Error: 'document.getElementById(...)'is null or not an object
  4. Code: 0
  5. URL: http://127.0.0.1/mainpage.htm
I just cannot figure out what's wrong here. It looks like it can't find the DIV i've selected. But it's there! The html code for calling the content is this:

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
  2. ajax_loadContent('dtree','leftmen1.html'); 
  3. </SCRIPT> 
Meaning it should get the content from leftmen1.html and put it in the DIV called "dtree"

Anyone?

Edit: I know that it can in fact find the leftmen1.html, cause if I change this to something else (a html file that doesn't excist) then I get no error. And of course no content in the DIV.

I've also tried using the code found here:

http://www.dynamicdrive.com/dynamici...jaxcontent.htm

And with the exact same result..
Nov 28 '07 #1
2 7305
acoder
16,027 Recognized Expert Moderator MVP
Can you post your code? What do you have on line 41?
Nov 28 '07 #2
kenny bones
4 New Member
Hi, I decided to go with ASP insted and just use the "include" function to do this. Works like a charm. Although, now I'm having some other problems with the other menu to get the "onstate" of the buttons to understand which site is open so that the tabs will look right.

http://www.thescripts.com/forum/thread748489.html

Help?
Dec 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
13840
by: Tony B | last post by:
Hi I need to insert a new node into an exisiting XML file using VBScript. The file has the following structure: <TRANSACTION> <ORDER> <BILLING>... </BILLING> <ORDER_TOTALS>... </ORDER_TOTALS> <ITEMS>
4
6321
by: Sergio del Amo | last post by:
i, I have the next html page <html> <head> <script> <!-- function insertcode() { var code ="<p> blablabal babala babababab</p><h1>here comes header</h1><span>fadfafa<a href=\"fadfaf\">anchor</a>blalbababa</span>"
16
17026
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
20
5667
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
2
2409
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe that I am not calling the function correctly. The MyInsertMethod function is the function that comes in the Web Matrix Toolbox <%@ Page Language="VB" %>
7
4878
by: Wojtek | last post by:
Hello, how can I transparently insert one XML file into another? I am looking for a method simmilar to the #include <file> known from the C language. To be more precise, an example: I have one file: MainDocument.xml <Document>
1
5040
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/db/VideoBlog.mdb") & ";" Set cmd = Server.CreateObject("ADODB.command") With cmd
0
2157
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include file="../Connections/conn.jsp" %> <% // *** Edit Operations: declare variables // set the form action variable String MM_editAction = request.getRequestURI(); if (request.getQueryString() != null && request.getQueryString().length() > 0) {
1
4847
by: deepaks85 | last post by:
Dear Friends, Please help me out where I am doing mistake...I am trying to insert records into my MSSQL database...but it always take me into the "page cannot be displayed"....Here is the code.... AddEOi.asp --------------------------------------------------------------------------------------------------- <%
0
10633
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
10375
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
10114
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...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
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
6880
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
5548
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.