limitphp Posted November 10, 2008 Share Posted November 10, 2008 On digg.com, when you click to digg a story, just the digg number count refreshes, but the page doesn't refresh. They aren't using iframes on the digg counts either. How do they do that? Does anyone have an idea? Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/ Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 Ajax most likely Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686885 Share on other sites More sharing options...
premiso Posted November 10, 2008 Share Posted November 10, 2008 AJAX. Basically when it clicks javascript makes a call back to the server than using elements on the page, such as a DIV they are able to update that specific element with Javascript. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686886 Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 You should read up on AJAX, and then read up on javascript libraries, like Prototype and jQuery. They simplify AJAX and make it easy to use. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686891 Share on other sites More sharing options...
limitphp Posted November 10, 2008 Author Share Posted November 10, 2008 I'm going to host my site on lunarpages. I have their basic plan to start off with. I don't see AJAX support. But I guess if my site becomes popular and I'm able to make some money to upgrade the plan, that is something I would like to get. That seems like a major improvement over php and asp. Being able to get javascript to make a call back to the server, that is freakin awesome. Thanks for the info, guys. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686916 Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 There's no such thing as Ajax support server-side (as long as your hosting has some support for server-side scripting - PHP included). Ajax is just JavaScript talking to server Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686918 Share on other sites More sharing options...
limitphp Posted November 10, 2008 Author Share Posted November 10, 2008 There's no such thing as Ajax support server-side (as long as your hosting has some support for server-side scripting - PHP included). Ajax is just JavaScript talking to server really....awesome.... I'm using wamp server 5.2.6 as my test machine....is there anything I need to do to get AJAX going? Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686927 Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 Nope, if you have PHP, you can do AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686929 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 But I guess if my site becomes popular and I'm able to make some money to upgrade the plan, that is something I would like to get. You don't need money just knowledge of how to do it. Being able to get javascript to make a call back to the server, that is freakin awesome. Yes, it is awesome! I also think it makes your site look more professional and faster for people to get/do what they want. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686930 Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 Correct. In fact I'm on WampServer and toying with Ajax right now. (Hey guys... you've got equal amount of posts at this time! Looks kewl! ) Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686932 Share on other sites More sharing options...
limitphp Posted November 10, 2008 Author Share Posted November 10, 2008 So, to get AJAX to do what digg does with their counter being updated, I guess I'll need to learn xml as well? Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686933 Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 Not necessarily. It's true that 'X' in 'Ajax' stands for XML but in fact you can do as well without it. (On the other hand, there's not that much to learn about XML to be able to use it with AJAX) Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686935 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 So, to get AJAX to do what digg does with their counter being updated, I guess I'll need to learn xml as well? Not necessarily. You can use pre-formatted HTML or JSON to format your data instead of XML. (Mchl, I know you just posted but I'm posting mine anyway! ) Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686936 Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 JSON is probably the niftiest method and it's very easy to do with PHPs built in json_encode and json_decode. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686937 Share on other sites More sharing options...
limitphp Posted November 10, 2008 Author Share Posted November 10, 2008 Ok, so basically, when someone clicks on vote, I want the vote number to update itself. Basically, it will be a query to select select songID FROM vote where songID = $songID. $voteCount=mysql_affected_rows(); Can you guys help me to do this, or do I need to read up on AJAX first. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686938 Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 JSON is probably the niftiest method and it's very easy to do with PHPs built in json_encode and json_decode. That's right, and that's the one I use. It was a bit awkward in the beginning, but now I think it's the best solution. Besides it's been designed to work with JavaScript, so it is faster. @Maq: I do this kind of thing all the time. Why waste what's been written anyways? @limitphp: It would be really good if you got some knowledge about AJAX before you start using it. The basics are pretty simple, and you can go through tutorials in less than a day. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686941 Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 You definitely need to read up on AJAX first. Also, use jQuery. You can see an example making an AJAX request in jQuery here: http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686946 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 @Maq: I do this kind of thing all the time. Why waste what's been written anyways? Exactly. Even though ours were very similar mine gave some examples of substitutions you could use instead of XML. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-686978 Share on other sites More sharing options...
limitphp Posted November 10, 2008 Author Share Posted November 10, 2008 You definitely need to read up on AJAX first. Also, use jQuery. You can see an example making an AJAX request in jQuery here: http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype So do you use jQuery instead of the xmlHttp.open?: xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-687024 Share on other sites More sharing options...
nitation Posted November 10, 2008 Share Posted November 10, 2008 you don't get anyone to write a complete script for you on PHPfreaks, Google beginners to AJAX and come back with questions. Remember to post your question in the right forum. This is strictly for PHP. My 2cent contribution Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-687044 Share on other sites More sharing options...
Mchl Posted November 10, 2008 Share Posted November 10, 2008 It's not like he asked for anyone to code anything... And I'm sure mods will move this topic if they'll find it necessary. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-687050 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 you don't get anyone to write a complete script for you on PHPfreaks He never asked anyone to write the whole script for him. And yes you can have people write a whole script for you, it's called the freelance section. Google beginners to AJAX and come back with questions Looking at his last post it looks like he did Google AJAX and is now asking for specific help. Remember to post your question in the right forum. This is strictly for PHP. You're right, I think there is an AJAX section, you may have better luck starting a whole new thread devoted to your next question. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-687053 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 It's not like he asked for anyone to code anything... And I'm sure mods will move this topic if they'll find it necessary. I don't think it has to be moved. Just end it here and start a new one in the appropriate section. Quote Link to comment https://forums.phpfreaks.com/topic/132162-update-a-page-without-refreshing-the-whole-page/#findComment-687057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.