SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [AJAX-related] onload doesn't work ?

    Hi there,

    I am trying to get AJAX edit in place to work. I have edit-file.php working like AJAX edit in place . But when i load edit-file.php in an Ajax div it stops working.

    I guess it has to do with <body onload="init()"> in edit-file.php

    How can i make this to work?

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have an url we can look at?


  3. #3
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry i don't have an url at the moment.

    But in general how do you enable php code or js scripts in say fileB, where fileB is "loaded" into a div in fileA???

  4. #4
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i have cut all the js-code out of edit-file.php and place it in fileA.php. Now most js functions work except:
    Code:
    function cancel()
        {
            $("title").innerHTML = <?php echo $row[\'title\']; ?>;
            $("body").innerHTML = <?php echo $row[\'body\']; ?>;
            $("save_settings").style.display = "none";
            $("edit_settings").style.display = "block";
        }
    $row is set in edit-file.php

    Any pointers?

  5. #5
    SitePoint Enthusiast Mr Moo's Avatar
    Join Date
    Oct 2007
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just off the top of my head:
    Code:
    function cancel()
        {
            $("title").innerHTML = "<?php echo $row[\'title\']; ?>";
            $("body").innerHTML = "<?php echo $row[\'body\']; ?>";
            $("save_settings").style.display = "none";
            $("edit_settings").style.display = "block";
        }
    Quote the strings?
    Not one shred of evidence supports the notion that life is serious.
    eternal.co.za - code, thoughts, rants and raves
    f1rivals.net - formula 1 forums, and, hopefully, soon, prediction game

  6. #6
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Mr Moo, already tried that.

    It has to do with the location of the php code (or js code).

    For instance:
    - loaded fileB.php(a form) into a div in fileA.php

    - a working fileB.php with form validation and database storage will not work if loaded into a div in fileA.php.

    - now when i copy all the form processing code from fileB into fileA it seems to work.

    - but i don't want to do it this way as fileA becomes very big.

    Any suggestions?

  7. #7
    SitePoint Enthusiast Mr Moo's Avatar
    Join Date
    Oct 2007
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some sample code would help. I mean some sample code from each file showing what you're trying to do.
    Not one shred of evidence supports the notion that life is serious.
    eternal.co.za - code, thoughts, rants and raves
    f1rivals.net - formula 1 forums, and, hopefully, soon, prediction game


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •