Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2491 > unrolled thread

how to implement AJAX to html

Started bymotix <motix@o2.pl>
First post2011-07-11 03:51 -0700
Last post2011-07-14 00:02 -0400
Articles 7 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  how to implement AJAX to html motix <motix@o2.pl> - 2011-07-11 03:51 -0700
    Re: how to implement AJAX to html Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-11 06:58 -0400
      Re: how to implement AJAX to html motix <motix@o2.pl> - 2011-07-11 04:38 -0700
        Re: how to implement AJAX to html Tim Streater <timstreater@greenbee.net> - 2011-07-11 14:37 +0100
    Re: how to implement AJAX to html "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-07-11 14:24 +0200
    Re: how to implement AJAX to html pittendrigh <sandy.pittendrigh@gmail.com> - 2011-07-13 12:32 -0700
      Re: how to implement AJAX to html Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-14 00:02 -0400

#2491 — how to implement AJAX to html

Frommotix <motix@o2.pl>
Date2011-07-11 03:51 -0700
Subjecthow to implement AJAX to html
Message-ID<f2f0d705-c5e7-45f6-94e6-5e582a3c06ec@gh5g2000vbb.googlegroups.com>
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:)

[toc] | [next] | [standalone]


#2492

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-07-11 06:58 -0400
Message-ID<ivel1l$l1r$1@dont-email.me>
In reply to#2491
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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#2493

Frommotix <motix@o2.pl>
Date2011-07-11 04:38 -0700
Message-ID<63e76969-237c-484e-bef5-69200b9b9e03@eb1g2000vbb.googlegroups.com>
In reply to#2492
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:)

[toc] | [prev] | [next] | [standalone]


#2495

FromTim Streater <timstreater@greenbee.net>
Date2011-07-11 14:37 +0100
Message-ID<timstreater-B6290B.14373111072011@news.individual.net>
In reply to#2493
In article 
<63e76969-237c-484e-bef5-69200b9b9e03@eb1g2000vbb.googlegroups.com>,
 motix <motix@o2.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

[toc] | [prev] | [next] | [standalone]


#2494

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2011-07-11 14:24 +0200
Message-ID<iveq1b$lif$1@dont-email.me>
In reply to#2491
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
--

[toc] | [prev] | [next] | [standalone]


#2539

Frompittendrigh <sandy.pittendrigh@gmail.com>
Date2011-07-13 12:32 -0700
Message-ID<50da15de-28cd-42fb-bb18-8f775031860f@z15g2000pre.googlegroups.com>
In reply to#2491
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>';

[toc] | [prev] | [next] | [standalone]


#2553

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-07-14 00:02 -0400
Message-ID<ivlpod$r2m$1@dont-email.me>
In reply to#2539
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@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web