Results 1 to 8 of 8

Thread: Load SLIDESHOW before Twitter api

  1. #1
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Load SLIDESHOW before Twitter api

    hi all

    i have this code in the <head></head> for my slideshow

    Code:
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery-ui.min.js" ></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#slideshow > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    });
    </script>
    and this twitter api code before end of body tag </body>
    Code:
    <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
    <script src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&callback=twitterCallback2&count=2"></script>
    THE PROBLEM :

    The header Slideshow start only after twitter tweets from the twitter api gets loaded.

    The header slideshow has to wait for twitter api to load.

    I want that The twitter api should load after the whole page has downloaded so that it doesnt interfere with slideshow.

    I want to load and run the header slideshow before twitter tweets api gets loaded.


    vineet

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Move this part:

    Code:
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#slideshow > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    });
    </script>
    to just before the twitter api. But also change it - getting rid of the highlighted parts, so that you end up with this:

    Code:
    <script type="text/javascript">
    $("#slideshow > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    </script>
    <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
    <script src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&callback=twitterCallback2&count=2"></script>
    </body>
    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi john

    This below code works fine when inserted before </body> tag

    Code:
    <script type="text/javascript">
    $("#slideshow > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    </script>
    But doesnt work when inserted inside <head></head>

    why ?

    vineet

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by vinpkl View Post
    . . . code works fine when inserted before </body> tag . . .

    . . . But doesnt work when inserted inside <head></head>

    why ?
    Because in the head, $("#slideshow > ul") doesn't exist yet. Anyways, that's where I told you to put it, just before the twitter api code there, which is (or you said it was) just before the </body> tag.

    Quote Originally Posted by jscheuer1 View Post
    Move this part . . . to just before the twitter api. But also change it - getting rid of the highlighted parts, so that you end up with this:

    Code:
    <script type="text/javascript">
    $("#slideshow > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    </script>
    <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
    <script src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&callback=twitterCallback2&count=2"></script>
    </body>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi john

    a new problem has arisen

    if i put these two scripts in my page
    Code:
    <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
    <script src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&callback=twitterCallback2&count=2"></script>
    then IE7 shots an error
    Code:
    Internet Explorer cannot open the Internet Site http://mysite.com
    Operation aborted
    Except IE7, ALL BROWSERS WORK FINE WITHOUT ANY ERROR.

    If i remove these two scripts, then there is no error in IE7.

    Vineet

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    You could ask the twitter api people, like if they have a forum for that or support.

    But it really depends upon where 'mysite.com' is coming from. I see you have:

    Code:
    ?screen_name=USERNAME
    Is that the actual code? If so it might be too generic. Is there a way you can give an actual username?

    But it could be coming from somewhere else. Is 'mysite.com' mentioned anywhere in any of the other code for the page?

    If so, that should be changed to reflect an actual site, probably that page's site.

    If you can't figure any of that out, here's something you can do, remove that code for IE 7 by surrounding it like so:

    Code:
    <!--[if lt IE 8]>
    <noscript>
    <![endif]-->
    <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
    <script src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&callback=twitterCallback2&count=2"></script>
    <!--[if lt IE 8]>
    </noscript>
    <![endif]-->
    That should prevent IE 7 and less from running that at all. IE 7 won't get the benefits of the twitter api, but unless you can fix the 'mysite.com' problem for IE 7, it probably wouldn't be anyway.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi john

    i replaced Client's Original Twitter ID with "USERNAME" bcoz i didnt wanted to post the client original twitter id.

    Otherwise the twitter tweets are displayed fine in firefox, chrome etc except IE7.

    the page which gets error is in the folder and not on the root www

    the page is located at

    domain.com/mysite/index.php

    vineet
    Last edited by jscheuer1; 10-28-2012 at 07:47 PM. Reason: delink

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    If I'm understanding you then, it's probably something in the twitter api. It's looking for that 'mysite' when it should probably be looking for the domain. The fact that this only happens in IE 7 could be a problem with that browser or the fact that only it reports the error. Does the code otherwise work as expected in IE 7?

    If it does, we can try to suppress the error. If it doesn't we may as well block the twitter api script using the method from my last post unless the twitter api folks can help you out on it.

    BTW, almost no one uses IE 7 any more. If you're stuck with Windows XP, and want IE, there's IE 8, and for Vista on up there's the far superior IE 9.

    I'm wondering though. Have you tested in IE 8? I ask because there are not too many errors of this nature in IE 7 that aren't also errors in IE 8. That would be of more concern, but I would still suggest the same general approach.

    You see, all browsers except IE 8 and less by default do not report errors. If it's not a fatal error, everything goes on fine and no one is the wiser unless you look under the hood at a console or something. But IE 8 and less by default report almost all errors, regardless of whether or not they're fatal ones. So if it's just the report that bothers you - like the script still works, we can try suppressing the report. If on the other hand the script doesn't work, then we need to remove it for that/those browser(s) where it doesn't work. Since it's the twitter api folks' script, we can't fix it. But they can or may know of a workaround. But as I say we can hold it back from browsers where it causes a problem. Or work at suppressing the error report.

    So which is it? Does it break the script or just annoy you because it shows that error?

    Oh, one more thing, if this is just a test environment and the finished page will be in the root of the domain, that error might go away once it's all set up like that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. slideshow that doesn't load all images first
    By ggalan in forum JavaScript
    Replies: 4
    Last Post: 09-11-2011, 04:33 PM
  2. Twitter!!
    By techie in forum Looking for such a script or service
    Replies: 8
    Last Post: 07-21-2010, 08:58 PM
  3. Ultimate Fade-in slideshow v2.4 takes a while to load
    By DesignAlot in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 07-21-2010, 04:46 AM
  4. Twitter Group
    By Nile in forum The lounge
    Replies: 0
    Last Post: 01-18-2009, 11:50 PM

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
  •