Advertisement
saasbook

ajax_rottenpotatoes.js

Apr 6th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. RP = {};
  2. RP.setup = function() {
  3. // add invisible 'div' to end of page:
  4. $('<div id="movieInfo"></div>').
  5. hide().
  6. appendTo($('body'));
  7. $('#movies a').click(RP.getMovieInfo);
  8. };
  9. RP.getMovieInfo = function() {
  10. $.ajax({type: 'GET',
  11. url: $(this).attr('href'),
  12. timeout: 5000,
  13. success: RP.showMovieInfo,
  14. error: function() { alert('Error!'); }
  15. });
  16. return(false);
  17. };
  18. RP.showMovieInfo = function(data) {
  19. // center a floater 1/2 as wide and 1/4 as tall as screen
  20. var oneFourth = Math.ceil($(window).width() / 4);
  21. $('#movieInfo').
  22. html(data).
  23. css({'left': oneFourth, 'width': 2*oneFourth, 'top': 250}).
  24. show();
  25. // make the Close link in the hidden element work
  26. $('#closeLink').click(RP.hideMovieInfo);
  27. return(false); // prevent default link action
  28. };
  29. RP.hideMovieInfo = function() {
  30. $('#movieInfo').hide();
  31. return(false);
  32. };
  33. $(RP.setup);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement