473,385 Members | 1,324 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,385 software developers and data experts.

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

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 7280
acoder
16,027 Expert Mod 8TB
Can you post your code? What do you have on line 41?
Nov 28 '07 #2
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
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>...
4
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...
16
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...
20
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...
2
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...
7
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...
1
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=" &...
0
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...
1
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.......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.