SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is this a job for ajax?

    i have a ranking system with 4 stars, when you rollover star 3 stars 1,2,& 3 turn gold and 4 turns gray, or if you roll over star 1, 1 turns gold and 2,3,&4 turn gray...you get the idea.....however the rollolvers look great (except for it taking a second or too to load, but thats a differnt topic) the thing is, when you click on a star the page has to refresh so it can save the choice to the DB, i think it looks stupid tho that you can rollover them and 'see' them changed but to actually set them that way the page must reload....i understand why but the average user wont. i dont know anything about ajax but i was thinking it might be possible to set this with ajax without reloading the page? can anyone tell me if thats possible and if so tell me how to do it or point me to somewhere that tells how?

    thanks
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see no problem with having a page refresh when rating an item. People try too hard to find things which might look good "Ajaxified", the fact is all you will do is most likely alienate users without javascript or modern browsers and reduce the stability of the application. Stick to the standard response/request paradigm unless the business logic of your application unequivocally requires a pseudo-real time interface.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bob Carologees
    I see no problem with having a page refresh when rating an item. People try too hard to find things which might look good "Ajaxified", the fact is all you will do is most likely alienate users without javascript or modern browsers and reduce the stability of the application. Stick to the standard response/request paradigm unless the business logic of your application unequivocally requires a pseudo-real time interface.
    man...
    you have to reflect about ajax a little bit more..
    regards...

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it's a job for.. superman!

    ok I'm sorry, I had to.. but anyways. Bob is right, there's too many people that are jumping on the AJAX/DHTML bandwagon while limiting their users for simple tasks. Javascript is, and always should be an enhancement to the interface, not a replacement. There are a few exceptions where an HTML interface would simply not work because of interactive requirements (such as games), or when someone simply wants to do a routine "Hey, look at this cool stuff" demo of some sort.

  5. #5
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so i should just let it refresh, cool...oh and i wasnt jumping on the ajax bandwagon lol.....i've never used ajax before nor know much about it, thats why i was asking.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  6. #6
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    man...
    you have to reflect about ajax a little bit more..
    regards...
    No I don't..."man". How about actually quantifying your argument instead of making some kind of gesture that I have no idea what I'm on about. You sound like a typical bandwagon jumper who doesn't really have a clue about the technology they are working with.

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've based your entire site navigation off javascript? That's an abomination to web design structure. There are people who probably won't bother with your site because basic navigation, something that javascript is not meant for is being utilized with it. You need to sit down and reconsider things, you're losing visitors.

  9. #9
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all my systems for vw, renault, seat , skoda... as well as my websites and cmss runs in ajax....
    thats not why i want it..simply my clients go crazy for it
    cheers

  10. #10
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That site must be nominated for "most pointless use of AJAX of the year award".

    If your clients love it fair enough, but the fact is you are the developer and know the technology and shouldn't be using AJAX just for the sake of it. I went through a speight of using it for everything, any sensible developer will come to realise the drawbacks of it and limit it's use to applications which fundamentally require it.

  11. #11
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.S - I'm suprised companies like Volkswagen would hire someone still using tables for structural design.

  12. #12
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the point is that any application you made as wel as websites have to become like desktop application.......
    much better if you drive javascript like mike foster into this concept....
    javascript generative components and xml data trading are our future you want it or not

  13. #13
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bob Carologees
    P.S - I'm suprised companies like Volkswagen would hire someone still using tables for structural design.
    i see you are green yet how old are you

  14. #14
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris_fuel
    You've based your entire site navigation off javascript? That's an abomination to web design structure. There are people who probably won't bother with your site because basic navigation, something that javascript is not meant for is being utilized with it. You need to sit down and reconsider things, you're losing visitors.
    all that was not made by me, the base structure of the site and the navigation, was made by another company called open door visions if you look at their site and then look at mine(well the company i work for's) you will realise that everything you see when you visit mine was completely redisgned, their own site looks like horse crap. ive been slowly redoing everything, but the navigation is based on the admin which was also made by them (granted i have redone most of it too) but its hard to correct everything someone else did.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  15. #15
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appreciate English isn't your first language. But if you can't be assed to raise any sensible points there isn't much point continuing this discussion.

    By the way, the fact you are a good coder doesn't make your argument any more valid - there are many flaws in AJAX currently and too many to simply ignore - look at Harry Fuecks site and many others who have gone to great depths in exposing these.

    Personally, having weighed up both sides, I'm sticking firmly to good old page refreshes.

  16. #16
    SitePoint Member bag's Avatar
    Join Date
    Jun 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by halfasleeps
    i have a ranking system with 4 stars, when you rollover star 3 stars 1,2,& 3 turn gold and 4 turns gray, or if you roll over star 1, 1 turns gold and 2,3,&4 turn gray...you get the idea.....however the rollolvers look great (except for it taking a second or too to load, but thats a differnt topic) the thing is, when you click on a star the page has to refresh so it can save the choice to the DB, i think it looks stupid tho that you can rollover them and 'see' them changed but to actually set them that way the page must reload....i understand why but the average user wont. i dont know anything about ajax but i was thinking it might be possible to set this with ajax without reloading the page? can anyone tell me if thats possible and if so tell me how to do it or point me to somewhere that tells how?

    thanks

    personally i think it would be quite a good use of ajax, since its really a waste of time to reload an entire page just for that, and would be very simple to do by the sounds of it "/
    and you wouldn't actually have to alienate anyone? all you would need is a fall back, so if javascript doesn't work, it will just send the information as it normally would "/

    Im not entirely sure how the "star" currently work though, but hypothetically your using a ordinary link

    starrate being how much its rated and item being whats being rated.
    HTML Code:
    <a href="script.php?starrate=4&item=5">
    after sending there normally it would hypothetically redirect back

    now do the same threw ajax in a very basic way (probably not particularly efficient)
    HTML Code:
    <script type="text/javascript">
    var xmlhttp;
    function savestar(rating,item){
    //create request object
    try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { // DontWork
    }
    // send the information without reloading
    xmlhttp.onreadystatechange = say_done;
    xmlhttp.open("GET", 'script.php?starrate=' + rating + '&item=' + item);
    xmlhttp.send(null);
    }
    function say_done(){
    if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
    //alert what we receive back, php script will ether give a Confirmation message it worked, or an error message if it didn't.
    alert(xmlhttp.responseText);
    }
    }
    </script>
    
    <a href="script.php?starrate=4&item=5" onClick="savestar(4,5); return false;">
    I know alot of people could probably do it better, but this is just a quick example i wrote just now (may be some stupid mistakes)

    If a person does not have javascript, the information would send normally. if they do, the onClick hander makes the ajax do it, and returns to stop the href link running

  17. #17
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still think it's unecessary.

  18. #18
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey bag, that works good.....but i have a function set to onmouseout to set the stars back to their original state whe you roll out, and it will still see the old number of stars not the new one.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  19. #19
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its a functoin that looks like this

    do_stars(start,end,id,count,btn1,btn2);

    the 4th arg 'count' is set to the number of stars their is, so that when they roll out without clicking it sets them back to what they are, i will need to change the 4th argument when they click is there any way to do that?

    so for instance after the onClick="" the onmouseout="do_stars(1,4,234,3,2,1)"
    needs to be change to onmouseout="do_stars(1,4,234,2,2,1)"

    any way to do that?
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  20. #20
    SitePoint Member bag's Avatar
    Join Date
    Jun 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    urmm im a little confused but, i think what you want could maybe be achieved by storing the number as a variable as opposed to hard coding it.
    Say somewhere earlier on
    Code:
    //set default stars count
    var number_stars = 3;
    then in the onclick have it change that variable to the wanted number
    Code:
    onclick="somefunction();number_stars=2;"
    then the onmouseout itself be set up like
    Code:
    onmouseout="do_stars(1,4,234,number_stars,2,1);"
    Maybe? Im not 100% on that though so my method may just cause a javascript error instead of actually helping "/

  21. #21
    SitePoint Enthusiast
    Join Date
    Aug 2002
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    use it

    I hate when page is reloaded for simple tasks, as your are, so go with AJAX. Not even with ajax. You do not need asynchronuos aproach. Look at this. You can have:
    Code:
        try{
      	 var requester = new XMLHttpRequest();
        }catch(error){
      	  try{
      	   var requester = new ActiveXObject("Microsoft.XMLHTTP");
      	 }catch(error){
      	  //nothing right now
           }
      }   
      
      function cast_vote(vote, object){
      requester.open("GET","http://www.yoursite.com/vote.php?rate='+vote,false);
      requester.send(null);
      doStuff(object.parentNode);
      }
      
      function doStuff(divWraper){
          var result=requester.responseText;
       //now you rewrite your stars with innerHTML inside div, do it by yourself
      }
    And, in yor html:
    HTML Code:
      <div><img onclick="cast_vote(1,this)" onmouseover="roll(1)"/>
     <img onclick="cast_vote(2,this)" onmouseover="roll(2)"/>
     <img onclick="cast_vote(3,this)" onmouseover="roll(3)"/>
     <img onclick="cast_vote(4,this)" onmouseover="roll(4)"/>
     <img onclick="cast_vote(5,this)" onmouseover="roll(5)"/>
      </div>
    It isn't semantiacal, but you got point.
    graphic, web, industry, animation - krdr ; )+)

  22. #22
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i said that ajax is the future and browsers navigation will be deprecated for a while..
    cheers

  23. #23
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    rails is the future

  24. #24
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bag
    urmm im a little confused but, i think what you want could maybe be achieved by storing the number as a variable as opposed to hard coding it.
    Say somewhere earlier on
    Code:
    //set default stars count
    var number_stars = 3;
    then in the onclick have it change that variable to the wanted number
    Code:
    onclick="somefunction();number_stars=2;"
    then the onmouseout itself be set up like
    Code:
    onmouseout="do_stars(1,4,234,number_stars,2,1);"
    Maybe? Im not 100% on that though so my method may just cause a javascript error instead of actually helping "/
    that works i just made it an array tho because their are several sets echoed out from php. so everytime i echo it with php i added to the array, then when i changed a star i set a function to change the value of that perticlar part of the array....so far it seems to work great. thanks
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.


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
  •