ajax javascript div help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaywebguy
    New Member
    • Mar 2008
    • 1

    ajax javascript div help

    I'm at a loss. Hoping someone out there can provide some insight into how to accomplish what I'm doing.

    Here is the link to the temp page I'm working on:


    Basically when you check a value, I pass a couple values through getXHTTP() to a coldfusion page, which then writes the values to the db, queries out all the records and displays the result set. This all takes place on a separate script page. The results are included on the main page once again through getXHTTP results.

    On the main page (units_setup.cf m) I also out put the values and include some javascript to hide/show some extra information between div tags. However when the new values are displayed through the call from getXHTTP, the new values will not access the javascript code from the main page.

    I think I understand why, because where I'm including the results from the page I'm calling between a couple div tags, isn't actually part of the page.

    Hopefully I haven't lost everyone. I guess my question is how can I get my displayed results to access or interact with javascript functions on the main page?

    Thanks for any insight you all can provide.

    Jason
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Hi Jason, welcome to TSDN!

    I see you're returning JavaScript in the response. To get this JavaScript to run, add it to a script tag in the head part of the main page, e.g.
    [code=javascript]var script = document.create Element("script ");
    script.appendCh ild(document.cr eateTextNode(js Text)); // jsText contains js code
    document.getEle mentsByTagName( "head")[0].appendChild(sc ript);[/code]

    Comment

    • ajaxphp
      New Member
      • Mar 2008
      • 3

      #3
      Hello, sir:

      I have similar problem.

      I used a mainpage to load javascript dynamically through ajax. The javascript is loaded on the body onload function. The problem is that the returned javascript cannot be used, looks like the scope is wrong. I used alert to show the script text, and it is correct.

      any clue to make the ajax returned javascript into gobal scope?

      Thanks

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Give an example of the response.

        Comment

        Working...