Rating the Rater **UPDATE**

One of the points of the star rater is that it should work without reloading the site (I know how much you all whine about the site load time). It seems to work fine in Fire Fox, but apparently it doesn’t in IE7. Because I love my readers (unlike many other blog authors who only see readers as things to aim at when urinating), I downloaded IE7 to try and figure that out. I hope you appreciate that given my aversion to Internet Explorer and downloading large updates from Microsoft.
BTW, this stuff is complicated. This rater alone involves Java, PHP, CSS, HTML, and SQL — each of which have their own little idiosyncrasies to keep track of. The problem is most likely in the Java that’s supposed to respond to the click instead of the hyperlink, but it works for IE7 on my test site so I’m having a little trouble tracking down the problem. Anyone have any tips on debugging this stuff beside putting it live and seeing whether it works or not? I really need to better analyze what happens at the click on the rater, but I’m new to web programming and am not sure how to isolate that.
I miss printf.
UPDATE:
With the help of readers Mark, E.T., and others, I think I have it working now. If any of you still find the rater refreshing the page (and you have Javascript enabled), please tell me. I’m new to the web programming, but this seemed a nice way to start to learn it so I can eventually add more features to IMAO and do some research I’ve been meaning to do…

35 Comments

  1. I, John McCain would like to take this opportunity to apologize in advance for the obvious gratuitous shots that this post will cause at my close personal friends on the other side of the isle! Senator Obama and Hillary Clinton are great Americans who I have worked closely with to serve the American people and they don’t deserve the insults and politics of personal destruction that this post will surely cause. I served in Vietnam by the way and was a POW!

  2. ussjimmycarter – I think John McCaan has a post for you in his new administration: chief apologist. You’ll have to give up Secretary of No Buggerin’, however.
    Frank, I, ussjimmycarter and John MacCon apologize for this off-topic post.

  3. As an IE7 user, the page loads after I click the star about half the time, and the other times it updates without loading. Weird?
    [Actually, I got it working in IE7 once so far, but haven’t been able to repeat it. I really wish I could get more data on what’s happening when I’m clicking. -Ed.]

  4. This rater alone involves Java, PHP, CSS, HTML, and SQL
    Then it’s a dumbass design. Roll your own, and stick to Javascript and CSS, or Java. I would even dump the SQL since you don’t have tens of thousands of readers, and just roll your own little CGI script that stashes the numbers in some plain-text database.
    KISS, eh?

  5. Install Fiddler (www.fiddlertool.com) to see the HTTP traffic; it often helps to see the actual request made by the client.
    As for debugging the JavaScript (which is not Java and not really related – just to help in your Google searches), your options are limited. The only way that’s ever helped me is to have Visual Studio installed (doesn’t have to be running), then go to Tools->Internet Options->Advanced. Un-check the boxes next to “Disable script debugging (Internet Explorer)” and “Disable script debugging (Other)”. You’ll now get a notification of every JS error with an option to debug in Visual Studio.
    Also, the IE Developer Toolbar (also available from Microsoft) is quite useful, but I don’t think it will help with your script problem.
    [Yeah… guess I need Visual Studio… -Ed.]

  6. Forgot – if you don’t have Visual Studio, the free version (Visual Web Developer Express) should be good enough to at least get you a better error with an accurate line number. Its debugging capabilities are more limited, though.
    [Anymore info on what’s happening would be helpful. Thanks. I’ll go download that. -Ed.]

  7. It also reloads on IE 6. Sorry but I’m at work and we’re stuck with the old browser until they make our payroll site compatible with current software and they won’t allow us to download any alternate software like Firefox.

  8. Let NO ONE speak poorly of FrankJ in my prescence again lest they want to fight!
    Anyone willing to pollute their computer with IE to try and help us poor peons stuck with the MS crap whilst goofing off at work is a HERO in my book.

  9. Yeah, you’re stuck with all of Bill Gates’ “new technology” promised years ago, delivered yesterday. All that harvested fruit… for fruitcakes.
    Oh, not you Brian.
    So, that means Frank is either using Apple or Linux.

  10. Jimmy, I’m just watching out for my good personal friend John McCain. We all know that this post was loaded. Java happens to rhyme with Obama…if you know what I mean! As for a post in the McCain administration, I’d sooner set my hair on fire while having sex with Hillary Clinton while she has sex with Cindy Sheehan while eating a plate full of dried worms!

  11. #10 – Posted by: Carl Pham on March 13, 2008 03:43 PM
    Thats what I was thinking. The code for something that simple should be very simple, just some Javascript, and a couple lines of PHP and CSS.

  12. Frank,
    The scripts use a behavior registration to add the on-click event to the anchor tags in the rating bar. This does not appear to be working for IE. I’m not that familiar with behaviors (I would just use the “brute-force” approach of adding the on-click handlers directly).
    You should be able to add alert statements to the behaviour.js file to see what is actually being passed as the behavior.
    What is supposed to happen is that it should associate a call to the sndReq() function found in rating.js instead of actually going to the URL in the href attribute of the anchor tag.
    [Yeah, I figured out that last part, but am having trouble figuring out why. I’m a newbie to web stuff, so you’ll need to explain a bit more. Do you have an example of these alert statement? -Ed.]

  13. Frank,
    I’ve been poking around a bit because you got me curious about behaviors and I cannot find any reference to Behavior.register at msdn.microsoft.com. It may be that it is non-functional. Do you know if the scripts work with IE6? The behavior documentation for IE uses external script components and CSS entries instead of Behavior.register.
    Javascript alert syntax is:
    alert( text );
    Here’s a good javascript reference site:
    http://www.webreference.com/javascript/reference/core_ref/ix.html
    Note that the above is Javascript only. It does not reference the browser objects.
    [Behavior.register is from the behavior.js which should also be running. Thanks for the help. -Ed.]

  14. Ok, I hadn’t looked closely at behavior.js. pretty slick.
    I just stepped through the whole mess in the debugger and it appears to have found all of the links and attached the on-click handler. Now it works for me. I’ll try clearing the browser cache and see if that makes a difference.
    [How do I get one of these debuggers you speak of? So far, I can find anyway to find what the Javascript is doing in IE7… if anything (though I’ll try the alerts later when less people will be on the site). -Ed.]

  15. Frank,
    I’m using Visual Studio 6 myself (it took 5 years before I finally figured out how to use the script debugger with javascript code in HTML). Microsoft Script debugger (free) should do the same. The trick is that (with VS6 anyway) is to load the page, then attach to the process running IE. After that you can set a breakpoint in one of the loaded documents and refresh the page (or trigger the javascript code with a link).
    I cleared my cache and restarted the browser. The problem comes back along with a Javascript error on startup. That error is in the code that modifies the onload event. After looking at it and looking at your page source I think I see the problem. Move the 3 lines of ratings include files down into the page head tag. They are actually outside of the HTML tag now.
    I think what is happening is that the script is executing before the page has loaded enough to establish that there is no current onload event handler (in the tag). This causes the error and the error prevents the code from running when the page does load.
    [So it wasn’t just my ignorance of Javascript; it was also my ignorance of HTML. Anyway, that seems to have done it. I’ll have to check out that debugger as I don’t know if I’ll be able to obtain Visual Studios. -Ed.]

  16. Yeah, and I was just kiddin’, Frank, about that block-structured C comment. We all know you’re an object-oriented, polymorphic, encapsulated geek with an attitude about conservative politics in which Java, PHP, CSS, HTML, and SQL are just means to an end!

  17. I am John McCain, War Hero and former POW! I’d like to take this opportunity to distance myself from senator Barack Obama! It has come to my attention that his pastor of 20 years is of questionable character and since I myself being beyond reproach, I have never known and have never talked with and have never met the senator from Idaho…err…Illinois…but I want to be perfectly clear that I still support my good friend senator Clinton whom I have worked with accross the isle on many issues on behalf of the American people and I will not tolerate pricks from IMAO taking shots at my good friend!

  18. The good news is that it is no longer reloading the whole damned page when I click the stars.
    I was going to send you a longwinded post about using AJAX (Asynchronous Javascript And Xml (eXtensible Markup Language)). In my line of work, I use ASP.NET’s “ScriptManager” and wrap the user controls in an “UpdatePanel”. Mind you, I have the luxury of an IIS 6 and Windows Server 2003 dedicated backend.
    PS. mark, VS6? Don’t make me laugh! Your Windows boots up in what, a day and a half? Hey fella, I betcha still livin’ in yo’ parents’ cella…

  19. Hey ussjimmycarter:
    Did you see that mccain’s “victory chairman” (or some such title) is none other than Carly Fiorina? She’s the ex – ceo of Hewlett Packard, fired for hiring private investigators to spy on board members to find out disclosed information from board meetings.
    Wonder what new imposition on the first amendment she and mccain are cooking up?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.