Simple AJAX article rating script

P1x44r

New member
Created this the other day. This does not use any fancy AJAX framework, but is a simple way to allow article rating via AJAX. It is IP-based to prevent multiple votes on the same item.

My way of contributing back to the community. :)

Right now I don't have the time to post explanation, but it should be easy enough for anyone to pick up and expand upon. The code might be a little messy, but I ripped this right out of my website and had to replace a bunch of wrappers with native calls(mostly for DB).

The only thing that might need a little explaining is my call in index.php

Code:
print get_article_rating(1, user_voted(1));

Number one(1) in both, first and second function calls is your article id that you want to enable voting on as pulled from the database.

If you got any questions, feel free to ask here, I'd be more than happy to help.

Get it here: http://www.p1x44r.com/files/

Demo is also available on my website. Just go to the front page and look right under each article preview section. You will see it current rating and will be able to cast your vote.

Enjoy!
 
Last edited:
Sorry, I don't do ghey sex aka .NET :bleh2:

sadhop.gif
 
No rationale, I was just playing with monkeydust.

I do know .NET, however, whenever there's a choice I will always choose open source license over others.
 
No rationale, I was just playing with monkeydust.

I do know .NET, however, whenever there's a choice I will always choose open source license over others.

You can't beat the price. Lucky for me my company gives me a copy of Visual Studio so I can have the best of both worlds!
 
You can't beat the price. Lucky for me my company gives me a copy of Visual Studio so I can have the best of both worlds!
The price plays a major role in my decision, yes. But additionally it's the community around open source products that usually make me thankful for choosing them(products). So much information and help out there, all available at no cost and within your reach.
 
Big corporations care more about support than upfront cost. When you have a team of highly paid developers working on a project you need to make sure the wheels keep moving as that would be more costly than the original cost of buying the development tools and hosting environments.
 
I am a huge .NET fan but I can see how MS has caused plenty of people to move towards open-source solutions. MS has been fairly schizo over the last 15 years with their direction. The evolution to .NET was not exactly a clear and clean process. They tend to make a lot of big changes instead of incrementally building on a solid base. The advantages of open-source solutions is that you have more control over migration and change. With MS you have to follow their lead as they will eventually drop support on you if you don't.

I hope, with the advent of .NET, that has all changed. This platform seems like the way it should have been done all along. I will personally drive up to Redmond and kick Bill Gates in the balls if he does another 180 degree change 5 years from now and .NET goes away!
 
Big corporations care more about support than upfront cost. When you have a team of highly paid developers working on a project you need to make sure the wheels keep moving as that would be more costly than the original cost of buying the development tools and hosting environments.
What support?

These same high paid developers could change and customize virtually anything about our open-source tools without waiting on MS to do so. Why should I be dependent on someone else to release my fix?
 
What support?

These same high paid developers could change and customize virtually anything about our open-source tools without waiting on MS to do so. Why should I be dependent on someone else to release my fix?

The theory is that you DON'T want your highly paid developers to have to do this. Open source is a double-edged sword in that it gives you complete ownership of everything. And. at the same time, you now have complete ownership of everything.

There are plenty of times you can run into a brick wall with MS solutions. But, there is plenty of support out there to help. Rarely, do I run into a situation where I would wish I could "do it myself" instead. There are always numerous ways to accomplish the task. If all else fails you can still whip out C++ and do it yourself if .NET doesn't already do it for you. (This includes extending developer tools, ...) But, in the VAST majority of cases MS has already done it for me so I can focus instead on creating valuable IPR for my company to sell.

Don't get me wrong, I have had those moments just like you describe. But, I have had many more where I could rapidly build solutions based on support already available and deploy it easily. The harsh reality is that my company can't afford to build a better compiler for the open source community. Instead, we need to create products that generate revenue or we are all out of a job!
 
The theory is that you DON'T want your highly paid developers to have to do this. Open source is a double-edged sword in that it gives you complete ownership of everything. And. at the same time, you now have complete ownership of everything.

There are plenty of times you can run into a brick wall with MS solutions. But, there is plenty of support out there to help. Rarely, do I run into a situation where I would wish I could "do it myself" instead. There are always numerous ways to accomplish the task. If all else fails you can still whip out C++ and do it yourself if .NET doesn't already do it for you. (This includes extending developer tools, ...) But, in the VAST majority of cases MS has already done it for me so I can focus instead on creating valuable IPR for my company to sell.

Don't get me wrong, I have had those moments just like you describe. But, I have had many more where I could rapidly build solutions based on support already available and deploy it easily. The harsh reality is that my company can't afford to build a better compiler for the open source community. Instead, we need to create products that generate revenue or we are all out of a job!

:arrow_up: Yeah, what he said.

:D
 
The theory is that you DON'T want your highly paid developers to have to do this. Open source is a double-edged sword in that it gives you complete ownership of everything. And. at the same time, you now have complete ownership of everything.

There are plenty of times you can run into a brick wall with MS solutions. But, there is plenty of support out there to help. Rarely, do I run into a situation where I would wish I could "do it myself" instead. There are always numerous ways to accomplish the task. If all else fails you can still whip out C++ and do it yourself if .NET doesn't already do it for you. (This includes extending developer tools, ...) But, in the VAST majority of cases MS has already done it for me so I can focus instead on creating valuable IPR for my company to sell.

Don't get me wrong, I have had those moments just like you describe. But, I have had many more where I could rapidly build solutions based on support already available and deploy it easily. The harsh reality is that my company can't afford to build a better compiler for the open source community. Instead, we need to create products that generate revenue or we are all out of a job!
Well, you can't say there's no support when it comes to open source. For example, I'm currently working with Drupal and if that's not rapid development I don't know what is.

In any case, we're getting way off-topic. Is is clear you got your priorities where I have mine, so we can agree to disagree I guess. This thread about AJAX rating script written in PHP. If some of you guys wants to give it a try in ASP.NET I'd be the first one to check it out! :D
 
Well, you can't say there's no support when it comes to open source. For example, I'm currently working with Drupal and if that's not rapid development I don't know what is.

In any case, we're getting way off-topic. Is is clear you got your priorities where I have mine, so we can agree to disagree I guess. This thread about AJAX rating script written in PHP. If some of you guys wants to give it a try in ASP.NET I'd be the first one to check it out! :D

My only comment is that it is a little hard to actually realize you just cast a vote. Maybe you should add to the rate_article function a "Vote Cast" prompt of some kind and an "Already Voted" message for articles that have been voted on already?

PS. I really like the clean layout of your site :up:
 
Yeah, I thought about it, but can't come up with anything so far because I'm kind of limited on space there if you noticed. Don't want to implement ugly JavaScript alerts to display those messages. :S
 
Here's a few more ideas ...

I agree the alerts are ugly. What about different color stars if you voted or not? And/Or you could just add text next to the stars that said either "Vote Now" or "Already Voted". Plus, if you already voted, why should the stars still change the cursor to a hand?
 
Back
Top