SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript not working in a file called by Ajax

    Hi,

    I have a php file that is loaded by ajax in my page. The problem i have, is that if i have some JS in a page loaded by Ajax, this JS does not work anymore. All the rest is working fine.

    Maybe there is something i don't get. Can you have JS in a file loaded by Ajax?

    Thanks

  2. #2
    SitePoint Guru
    Join Date
    May 2004
    Location
    santa rosa, ca
    Posts
    969
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you can. It might help if you can post the code so that we might better see what is wrong.
    nondenominational, noncommercial, nonprofit,
    listener-supported, 24-hour, Christian ministry:
    Listen Live Online

  3. #3
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you mean that the script loaded in Ajax request is not working?

    Actually scripts loaded in Ajax request will not work unless you evaluate them.

    If you use any JavaScript library (like jQuery, prototype etc), then they will evaluate script inside the response, so that the loaded script will work.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so what is evaluating the script? I do not use librairies

    Thanks

  5. #5
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to use eval function. To make the scripts in the response work. But you may not be able to eval entire Ajax response.


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
  •