www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-04-2009, 04:51 PM
    looloo2009 looloo2009 is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 3
    Get element using getElementById on an Ajax processed page

    Hello guys

    Ive got an strange problem with my AJAX and javascript codes

    I have a page default.asp initiates an ajax call to results.asp then content of this page which is in XML will be placed in a DIV on the default.asp page.
    The main AJAX script is in a js file which is included in default.asp file. Standard Ajax stuff.
    In the new contents of the DIV which is loaded from results.asp we have a new DIV which we load some other results from another page

    This is the DIV in default.asp page which we load resutls from results.asp into that
    Code:
    <div id="first_ajax"></div>
    This is the second DIV in results.asp page (exactly in that section which we called previously using AJAX call on default.asp) So this DIV is created using the first AJAX call and is loaded as a result into the above DIV

    Code:
    <div id="second_ajax"></div>
    I have a link in the result of first page in the first DIV which is like this

    Code:
    <a href="javascript:doThisExternalFunction()">Click here</a>
    which call a function from the external js file and load the result in the second DIV, I get result in that js file and load them into the DIV using

    Code:
    document.getElementById('second_ajax').innerHTML
    everything is Okay and it works fine in IE , but the problem is that it doesn't work in FF or Opera, I get the error

    Code:
    document.getElementById('second_ajax') is null
    It can't find the element in Ajax loaded page,
    its strange coz It works fine in IE

    Thanks in advance
    Reply With Quote
      #2  
    Old 11-04-2009, 07:07 PM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    Check if you are calling getElementById after creating the element, consider the rendering timestamp. And also if you are using frames, this can lead to "document" pointer complications. If you post the complete source, or the link to it, more help can be possible my friend.
    Reply With Quote
      #3  
    Old 11-04-2009, 07:34 PM
    looloo2009 looloo2009 is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 3
    Hello
    Thanks a lot for ur reply

    As I said before it is working in IE without any problem, doesn it make sense ?
    I'll try to put the source here, its a little bit complicated coz its a small part of a big project
    Reply With Quote
      #4  
    Old 11-04-2009, 08:57 PM
    looloo2009 looloo2009 is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 3
    Im confused
    I just created a demo for that and it workd fine in FF , I don't know why it doesn't work when I have it in my main project

    What is that timestamp which u said ?
    sorry Im not good at javascript
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:14 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.