FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to implement AJAX to html
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
how to implement AJAX to html [message #174809] Mon, 11 July 2011 10:51 Go to next message
motix is currently offline  motix
Messages: 2
Registered: July 2011
Karma: 0
Junior Member
Hi guys, i am quite new with AJAX, i tried to implement this code --->
http://www.outcut.de/MooFlow/example-ajax.html in different ways, but
i can not make it work..Could anyone possibly explain what should i do
to make it work? thanks a lot:)
Re: how to implement AJAX to html [message #174810 is a reply to message #174809] Mon, 11 July 2011 10:58 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 7/11/2011 6:51 AM, motix wrote:
> Hi guys, i am quite new with AJAX, i tried to implement this code --->
> http://www.outcut.de/MooFlow/example-ajax.html in different ways, but
> i can not make it work..Could anyone possibly explain what should i do
> to make it work? thanks a lot:)

AJAX isn't PHP. Try a more appropriate newsgroup, such as
comp.lang.javascript.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: how to implement AJAX to html [message #174811 is a reply to message #174810] Mon, 11 July 2011 11:38 Go to previous messageGo to next message
motix is currently offline  motix
Messages: 2
Registered: July 2011
Karma: 0
Junior Member
On Jul 11, 11:58 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 7/11/2011 6:51 AM, motix wrote:
>
>> Hi guys, i am quite new with AJAX, i tried to implement this code --->
>> http://www.outcut.de/MooFlow/example-ajax.htmlin different ways, but
>> i can not make it work..Could anyone possibly explain what should i do
>> to make it work? thanks a lot:)
>
> AJAX isn't PHP.  Try a more appropriate newsgroup, such as
> comp.lang.javascript.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

ok, sorry:)
Re: how to implement AJAX to html [message #174812 is a reply to message #174809] Mon, 11 July 2011 12:24 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 11/07/2011 12:51, motix escribió/wrote:
> Hi guys, i am quite new with AJAX, i tried to implement this code --->
> http://www.outcut.de/MooFlow/example-ajax.html in different ways, but
> i can not make it work..Could anyone possibly explain what should i do
> to make it work? thanks a lot:)

While PHP is one of the tools you can use to feed AJAX applications, I
hardly see any need to use PHP with this tutorial since it does nothing
else than loading static HTML. Get your JavaScript done and care about
PHP later.

Also, be aware that if you provide "does not work" as only info, you may
get "then fix it" as only answer ;-)


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: how to implement AJAX to html [message #174813 is a reply to message #174811] Mon, 11 July 2011 13:37 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<63e76969-237c-484e-bef5-69200b9b9e03(at)eb1g2000vbb(dot)googlegroups(dot)com>,
motix <motix(at)o2(dot)pl> wrote:

> On Jul 11, 11:58 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> On 7/11/2011 6:51 AM, motix wrote:
>>
>>> Hi guys, i am quite new with AJAX, i tried to implement this code --->
>>> http://www.outcut.de/MooFlow/example-ajax.htmlin different ways, but
>>> i can not make it work..Could anyone possibly explain what should i do
>>> to make it work? thanks a lot:)
>>
>> AJAX isn't PHP.  Try a more appropriate newsgroup, such as
>> comp.lang.javascript.

> ok, sorry:)

You can also see here:

<http://www.clothears.org.uk>

for a simple example including the PHP part.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: how to implement AJAX to html [message #174855 is a reply to message #174809] Wed, 13 July 2011 19:32 Go to previous messageGo to next message
pittendrigh is currently offline  pittendrigh
Messages: 4
Registered: December 2010
Karma: 0
Junior Member
On Jul 11, 4:51 am, motix <mo...@o2.pl> wrote:
> Hi guys, i am quite new with AJAX, i tried to implement this code --->http://www.outcut.de/MooFlow/example-ajax.htmlin different ways, but
> i can not make it work..Could anyone possibly explain what should i do
> to make it work? thanks a lot:)

Just to get Jerry to jiggle a bit (it's always fun to watch what
happens) here's some simple PHP and ajax mushed together.

mkdir slideshow
....copy some images into slideshow
make a file named nextimage.php that has the following contents:

<?php
session_start();
$arrname = $_GET['arr'];
$_SESSION['cnt'] += 1;
if($_SESSION['cnt'] > count($_SESSION[$arrname])-1)
$_SESSION['cnt'] = 0;
echo $_SESSION[$arrname][$_SESSION['cnt']];
?>

make an index.php that has the following contents:
<?php

session_start();

function mk_rand_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

function is_image($file)
{
$ret=FALSE;
$dotpos = strrpos($file,'.');
if($dotpos)
{
$suffix = substr($file,$dotpos+1);
if(stristr($suffix,'jpg')
|| stristr($suffix,'jpeg')
|| stristr($suffix,'gif')
|| stristr($suffix,'png')
){ $ret=TRUE;}
}

return $ret;
}

function getImageFilenames($dir) {
$slideshowFilenames = array();
$LclCnt = 0;
if ($dir_handle = opendir($dir)) {
while (($file = readdir($dir_handle)) != false) {
if ($file[0] != '.' && is_image($file)) {
$slideshowFilenames[$LclCnt] = $file;
$LclCnt++;
}
}
closedir($dir_handle);
} else {
echo "failed to opendir $dir for some reason<br>";
exit();
}
return $slideshowFilenames;
}

if(!isset($_SESSION['slideshowFilenames']))
{
$_SESSION['slideshowFilenames'] = getImageFilenames("slideshow");
$_SESSION['cnt'] == count($_SESSION['slideshowFilenames'])-1;
}

echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>MRB Slideshow</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /
>
<script type="text/javascript">
var http = createRequestObject();

function createRequestObject()
{
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}

function startMeUp()
{
http.open(\'get\', \'nextimage.php?arr=slideshowFilenames\');
http.onreadystatechange = handleResponse;
http.send(null);
setInterval("mkRequest()", 3500);
}

function mkRequest()
{
http.open(\'get\', \'nextimage.php?arr=slideshowFilenames
\');
http.onreadystatechange = handleResponse;
http.send(null);
}

function handleResponse()
{
if(http.readyState == 4)
{
var response = http.responseText;
var obj = document.getElementById(\'foo\');
obj.style.background = \'url(slideshow/\' + response +
\') no-repeat center center\';
}
}
</script>
';


mk_rand_seed();
$def = $_SESSION['slideshowFilenames']
[rand(0,count($_SESSION['slideshowFilenames']))-1];
echo '
<style>
#foo {
width: 400px; height: 300px;
background: url(slideshow/'.$def.') no-repeat center
center;
}
</style>
</head>
<body onload="startMeUp()">
<div id="foo"></div>
</body>
</html>';
Re: how to implement AJAX to html [message #174868 is a reply to message #174855] Thu, 14 July 2011 04:02 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 7/13/2011 3:32 PM, pittendrigh wrote:
> On Jul 11, 4:51 am, motix<mo...@o2.pl> wrote:
>> Hi guys, i am quite new with AJAX, i tried to implement this code --->http://www.outcut.de/MooFlow/example-ajax.htmlin different ways, but
>> i can not make it work..Could anyone possibly explain what should i do
>> to make it work? thanks a lot:)
>
> Just to get Jerry to jiggle a bit (it's always fun to watch what
> happens) here's some simple PHP and ajax mushed together.
>
> mkdir slideshow
> ...copy some images into slideshow
> make a file named nextimage.php that has the following contents:
>

What do you need AJAX for? The answers here were correct and much better.

I guess if all you have is a hammer, everything is a nail.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with special char in MySQL and XML
Next Topic: Restricting access to a website
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 09:34:32 GMT 2024

Total time taken to generate the page: 0.02851 seconds