Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic jQuery loading, why script is executed 2 times?

    Hi,

    I am making a widget to work on any site, that means not my site, so I have no control of what other libraries are used on the page.
    Thats why I am loading my own jQuery libraries dynamically and then execute my own code.

    An issue I have that some sites are loading fine and all is working as expected, but some sites are executing the code 2 times.

    I have made a page dump and put on my own server, so I can replicate the issue better.

    GOOD: here is a page that works OK: (see the button that says: send these contact details and map to your mobile.)
    Code:
    http://test.plustest.info/suffolk/contact.html
    BAD: here is the page that shows the button I am trying to load 2 times:
    Code:
    http://test.plustest.info/cream.html
    As you can see the button appears 2 times, which is wrong...
    Even it shows 2 times, the popup appears just ok when you click on the button.

    Would anyone be able to check what can be wrong here?
    the code is in the:
    Code:
    <div id="now_send_it_wrapper">
    so its easier to find.

    Any help would be much appreciated.

    Thanks,
    Vladas

  • #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    375
    Thanks
    9
    Thanked 55 Times in 54 Posts
    Maybe because the script is a child of (within) the target div it is trying to modify:
    Code:
    <div id="now_send_it_wrapper">
      <script src="http://beta.nowsend.it/get/button/81" type="text/javascript"></script>
    </div>
    Try separate them as siblings, like below:
    Code:
    <div id="now_send_it_wrapper"></div>
    <script src="http://beta.nowsend.it/get/button/81" type="text/javascript"></script>

  • #3
    New to the CF scene
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    tried that, but it looks ok on the other examples, it is just that one site I am having such issues. Not sure if it is because the other libraries doing something weird as other sites are all fine...

    Cheers,
    Vladas


  •  

    Tags for this Thread

    Posting Permissions

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