Re: [PHP] Any Running Simple Ajax Sample for Php
On Fri, May 2, 2008 at 4:31 PM, Jon L. [EMAIL PROTECTED] wrote: If you aren't already, I recommend putting to use a JS library with Ajax support. Nothing else, they can reduce the browser compatibility overhead coding you'll need to do. I found that they also reduce or eliminate some memory leaks in the web browser that seem to be common for most of the AJAX examples I have seen on the web. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any Running Simple Ajax Sample for Php
On Sat, May 3, 2008 at 4:31 AM, Jon L. [EMAIL PROTECTED] wrote: If you aren't already, I recommend putting to use a JS library with Ajax support. Nothing else, they can reduce the browser compatibility overhead coding you'll need to do. You can pick any of many, but I'm more familiar with Prototype: http://prototypejs.org/ ## credits.php ?php /* ... */ // determine value for $credits print min($credits, 0); ? ## credits.html - html body div id=creditsChecking credits.../div script src=prototype.js/script script type=text/javascript /*** Reference ***/ http://prototypejs.org/api/periodicalExecuter http://prototypejs.org/api/ajax/request http://prototypejs.org/api/element/observe function creditsCheck(pe) { new Ajax.Request('foobar.php', { method: 'get', parameters: {ts: (new Date()).getTime()}, // cache prevention onSuccess: function (transport) { var elem = $('credits'); if (Number(transport.responseText) 0) { elem.update('Credits remaining: ' + transport.responseText); } else { elem.update('Credits have expired.').setStyle({background: '#f00'}); pe.stop(); } }, onFailure: function () { $('credits').update('Could not determine credits.').setStyle({background: '#f00'}); } }); } document.observe('dom:loaded', function () { var pe = new PeriodicalExecuter(creditsCheck, 60); creditsCheck(pe); // first check }); /script /body /html - Jon L. On Fri, May 2, 2008 at 4:13 AM, Heysem KAYA [EMAIL PROTECTED] wrote: Hi, I would like to check each minute whether the user credit is finished and update the relevant place on page. So I have downloaded however was not able to run some sample ajax code. Is there anyone who has such a simple code to implement? Thanks, Heysem Kaya jQuery library also can do AJAX thing in relatively simple way. check jquery.com
[PHP] Any Running Simple Ajax Sample for Php
Hi, I would like to check each minute whether the user credit is finished and update the relevant place on page. So I have downloaded however was not able to run some sample ajax code. Is there anyone who has such a simple code to implement? Thanks, Heysem Kaya
[PHP] Any Running Simple Ajax Sample for Php
Hi Heysem, So what you want is an ajax script that will call a php page every minute, and check for a result (assuming boolean) of 1 or 0? That shouldn't be too hard. First, I need to know more information about the page, such as the id tag of the element you want updated, and how severe the change. If it's a simple word, it's easy to do. If you could post more information (and possible what you have tried already, and maybe we can just fix that), I should be able to help you out more. Regards, - Craige On Fri, May 2, 2008 at 5:13 AM, Heysem KAYA [EMAIL PROTECTED] wrote: Hi, I would like to check each minute whether the user credit is finished and update the relevant place on page. So I have downloaded however was not able to run some sample ajax code. Is there anyone who has such a simple code to implement? Thanks, Heysem Kaya -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any Running Simple Ajax Sample for Php
If you aren't already, I recommend putting to use a JS library with Ajax support. Nothing else, they can reduce the browser compatibility overhead coding you'll need to do. You can pick any of many, but I'm more familiar with Prototype: http://prototypejs.org/ ## credits.php ?php /* ... */ // determine value for $credits print min($credits, 0); ? ## credits.html - html body div id=creditsChecking credits.../div script src=prototype.js/script script type=text/javascript /*** Reference ***/ http://prototypejs.org/api/periodicalExecuter http://prototypejs.org/api/ajax/request http://prototypejs.org/api/element/observe function creditsCheck(pe) { new Ajax.Request('foobar.php', { method: 'get', parameters: {ts: (new Date()).getTime()}, // cache prevention onSuccess: function (transport) { var elem = $('credits'); if (Number(transport.responseText) 0) { elem.update('Credits remaining: ' + transport.responseText); } else { elem.update('Credits have expired.').setStyle({background: '#f00'}); pe.stop(); } }, onFailure: function () { $('credits').update('Could not determine credits.').setStyle({background: '#f00'}); } }); } document.observe('dom:loaded', function () { var pe = new PeriodicalExecuter(creditsCheck, 60); creditsCheck(pe); // first check }); /script /body /html - Jon L. On Fri, May 2, 2008 at 4:13 AM, Heysem KAYA [EMAIL PROTECTED] wrote: Hi, I would like to check each minute whether the user credit is finished and update the relevant place on page. So I have downloaded however was not able to run some sample ajax code. Is there anyone who has such a simple code to implement? Thanks, Heysem Kaya