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

AJAX Error

384 256MB
I have the below link using the below ajax code and its throwing up the below error, can anyone help, I've been at it for ages and just can't figure it out, thanks for your help in advance.
Error: document.getElementById(containerid) is null
Source File: http://localhost/admin/useradmin.php?func=1#
Line: 69
Expand|Select|Wrap|Line Numbers
  1. <a onclick="getcontent('../ajax-111-ca+421/', 'span1'); return false;" href="#">
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2.     var loading_img = '/media/images/layout/loading.gif';
  3.     var loading_msg = ' Loading...';
  4.     var xmlhttp_obj = false;
  5.  
  6.     function xmlhttp()
  7.     {
  8.         if (window.XMLHttpRequest)
  9.         { // if Mozilla, Safari etc
  10.             xmlhttp_obj = new XMLHttpRequest();
  11.         }
  12.         else if (window.ActiveXObject)
  13.         { // if IE
  14.             try
  15.             {
  16.                 xmlhttp_obj = new ActiveXObject("Msxml2.XMLHTTP");
  17.             }
  18.             catch (e)
  19.             {
  20.                 try
  21.                 {
  22.                     xmlhttp_obj = new ActiveXObject("Microsoft.XMLHTTP");
  23.                 }
  24.                 catch (e)
  25.                 {
  26.  
  27.                 }
  28.             }
  29.         }
  30.         else
  31.         {
  32.             xmlhttp_obj = false;
  33.         }
  34.  
  35.         return xmlhttp_obj;
  36.     }   //get content via GET
  37.  
  38.     function getcontent(url, containerid)
  39.     {
  40.         var xmlhttp_obj = xmlhttp();
  41.         document.getElementById(containerid).innerHTML = '<img src="' + loading_img + '" />' + loading_msg;
  42.         xmlhttp_obj.onreadystatechange=function()
  43.         {
  44.             loadpage(xmlhttp_obj, containerid);
  45.         }
  46.         xmlhttp_obj.open('GET', url, true);
  47.         xmlhttp_obj.send(null);
  48.         alert(url);
  49.     }     
  50.  
  51.     function loadpage(xmlhttp_obj, containerid)
  52.     {
  53.         if ( xmlhttp_obj.readyState == 4 && xmlhttp_obj.status == 200 )
  54.         {
  55.             document.getElementById(containerid).innerHTML = xmlhttp_obj.responseText;
  56.         }
  57.     }
  58. //]]>
  59.  
  60. </script>
  61.  
Aug 22 '09 #1
4 1745
Do this in your browser:
containerid?
Shouldn't that be "document.containerid"?
Aug 22 '09 #2
gits
5,390 Expert Mod 4TB
could you try to trace/alert the containerid? the error is thrown when document.getElementById() doesn't find the element and you try to use an object's method or property that doesn't exist ... so currently in fact you try something like:

Expand|Select|Wrap|Line Numbers
  1. null.innerHTML = 'foo'
which throws the error. may be you are passing the wrong id or you don't pass the id correctly? could you post how you do the call?

kind regards
Aug 23 '09 #3
ziycon
384 256MB
Sorted it out, I'm pasing 'span1' into the function but on the webpage i had the span set as:
Expand|Select|Wrap|Line Numbers
  1. <span1></span1>
When it should have been:
Expand|Select|Wrap|Line Numbers
  1. <span id="span1"></span>
Thanks for your help.
Aug 24 '09 #4
gits
5,390 Expert Mod 4TB
glad to hear that you found it out :)

kind regards
Aug 24 '09 #5

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

Similar topics

5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
10
by: celoftis | last post by:
Using VS 2005: This morning, following the instructions here: http://ajax.asp.net/docs/overview/InstallingASPNETAJAX.aspx, I installed ASP.NET AJAX on my WinXP Pro development machine. Following...
4
by: NOTICIAS | last post by:
Hi everybody. A very basic web page using an ScriptManager and a RoundedCornersExtender fails loading at a shared hosting environment. In my local server, such page loads correctly. I'm...
5
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
2
by: germ | last post by:
doing a simple page webmethod call an a page via PageMethods works fine in ie7 & opera9 the same call on firefox ( and I assume netscape ) generates the following error : Error: " nsresult:...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
2
by: =?Utf-8?B?Q2VzYXI=?= | last post by:
I have the ASP.NET 2.0 AJAX Extensions 1.0 installed (v1.0.61025). As to the web.config file, I'm using the one created using the ASP.NET AJAX-Enabled website ... This error is due to that I'm...
9
by: Trapulo | last post by:
Hello, with ASP.NET 2.0 Ajax every unexpected error is managed client-side with a popup that reports the error to the user. In ASP.NET 3.5 this behavor has been changed: how can I have a similar...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.