Mise en place de commentaires ajax

Posted Thursday, December 8, 2005

Filed under: , , ,

J'ai voulu tester ajax, je vous encourage à tenter de laisser un commentaire pour dire si ça marche, et avec quoi. Les détails suivent pour ceux qui lisent tout.

Mon premier essai, en local, ne marchait pas: la console javascript parlait d'une "uncaught exception". En clair, Firefox bloque les scripts (ajax par exemple) qui utilisent des données d'un autre domaine. Un tour au serveur s'impose donc...

J'ai utilisé la fonction jah telle quelle: le script tient en quelques lignes et devrait marcher sur le fox, ie, et les navigateurs connaissant XMLHttpRequest.

[UPDATE: IE s'étouffe sur l'appel au script dans la balise head et n'affiche que l'image de fond. Tout comme Opera. Bizarre bizarre...]

[UPDATE 2:
Résolu!
Pour IE, on ne peut pas écrire
<script src="" />

Il faut fermer avec une balise complète
<script src=""></script>]

[UPDATE 3:
Mad4milk propose une version "light" de prototype (librairie javascript ultra-complète).]

[UPDATE 4:
A la demande générale, voici la procédure à suivre.

  1. Appeler le script "jah.js" (javascript, 1ko) dans le head de la page où il est nécessaire.
  2. Ajouter un conteneur (p, div, au choix) qui sera remplacé par le contenu dynamique.
  3. Créer une page vide ne contenant que le code à insérer (formulaire, texte, ce que vous voulez).
  4. Programmer votre application pour qu'elle traite la réponse du client s'il y en a une.

Et voilà! Vous pouvez adapter à votre aise évidement.
Notament, il serait bon que cliquer "envoyer" envoie les données sans afficher de page vierge. Mais on parle de trois lignes de javascript, n'en demandez pas trop...]

Comments disabled because of spammers.

comment #1 On 08/12, Korbo wrote :

Ben ça a l'air de marcher... Chouette!

comment #2 On 08/12, BenF wrote :

tagada pouet pouet

comment #3 On 08/12, BenF wrote :

Sous Firefox, ça a l'air de passer, effectivement :-)

comment #4 On 08/12, BenF wrote :

Sous IE également.

comment #5 On 08/12, Fetard wrote :

Ca marche sous Fx 1.5/Win2000 SP4

comment #6 On 08/12, Korbo wrote :

Et Opera 8.5 aussi sous XP

comment #7 On 08/12, Fetard wrote :

Par contre, ca marque "Comment added" sans aller plus loin...

comment #8 On 09/12, Korbo wrote :

Oui, je travaille là-dessus. Un petit meta refresh avec url=$http_header devrait faire l'affaire.

comment #9 On 09/12, Korbo wrote :

Voyons voir... Oui, ça semble marcher. Pas de raisons que ça ne marche pas d'ailleurs!

comment #10 On 10/12, Fetard wrote :

Test

comment #11 On 20/04, alberto wrote :

test

comment #12 On 27/04, Anonyme wrote :

ben ça marche

Balance les codes maintenant

comment #13 On 19/07, test wrote :

test

comment #14 On 23/07, TEE wrote :

TEST

comment #15 On 23/07, zae wrote :

bsjza

comment #16 On 23/07, test wrote :

test

comment #17 On 26/07, test wrote :

test

comment #18 On 09/10, coucou wrote :

coucou

comment #19 On 22/10, azer wrote :

Ben lol

comment #20 On 27/11, dis wrote :

Yeah la classe !

comment #21 On 10/12, lmaix wrote :

On dirait que ca marche ouai !

comment #22 On 21/12, hjk wrote :

test

comment #23 On 02/01, test wrote :

test

comment #24 On 05/01, r wrote :

j'essaie

comment #25 On 26/01, fdsf wrote :

et

comment #26 On 19/02, gfgf wrote :

gfgfgf

comment #27 On 20/02, givid wrote :

oups

comment #28 On 20/02, givid wrote :

oups 2

comment #29 On 23/02, jerome wrote :

nice

comment #30 On 23/02, jerome wrote :

nice

comment #31 On 01/03, TiBS wrote :

test

comment #32 On 05/03, :) wrote :

ca marche:)

comment #33 On 17/03, djfdlkfj wrote :

trestg mlfk gmlfkjg mmf

comment #34 On 25/03, m wrote :

commentaire en ajax

comment #35 On 01/04, sdcsc wrote :

dscsdc

comment #36 On 14/04, test wrote :

nice

comment #37 On 30/04, big wrote :

ca fonctionne

comment #38 On 03/05, wrote :

ttt

comment #39 On 14/05, test wrote :

test

comment #40 On 15/05, gewix wrote :

lol c de la super bal ce truc!! ;-)

comment #41 On 30/05, wrote :

test

comment #42 On 05/06, test wrote :

test

comment #43 On 05/06, moi meme wrote :

ben moi aussi je test alors

comment #44 On 11/06, test wrote :

test

comment #45 On 11/06, asdsad wrote :

sadasdsadasd

comment #46 On 13/06, asdasd wrote :

asdasd

comment #47 On 02/07, val wrote :

ça marche sous safari 3 (mac)

comment #48 On 13/07, test wrote :

test

comment #49 On 13/07, test wrote :

teeeee

comment #50 On 21/07, Test wrote :

Test

comment #51 On 24/07, john wrote :

:)

comment #52 On 08/08, Micha wrote :

test =X

comment #53 On 05/09, reg wrote :

gregeg

comment #54 On 02/10, wrote :

bon un petit test sous FF

comment #55 On 05/10, dsqdsq wrote :

testtttttttttttttt

comment #56 On 07/10, wrote :

essa

comment #57 On 21/10, mimir wrote :

je test un com ^^

comment #58 On 29/11, ryry wrote :

trtyry

comment #59 On 03/12, fsdfdsf wrote :

fdsfsdfsd

comment #60 On 03/12, Stef wrote :

Ouep ça marche bien ton script, tu devrais le publier pour en faire bénéficier ceux qui, comme moi, ne sont pas fort en codage!
Joli site, félicitations!!

comment #61 On 03/12, Goulven Champenois wrote :

@Stef:
Le script est disponible, c'est expliqué dans Update4.
Néanmoins ce n'est pas la meilleure façon de procéder: il manque la gestion d'erreur, le code est inutilement répété pour IE, etc...
On trouvera un début d'explication par Xavier Borderie dans son article sur Javascript non intrusif sur Journal du Net : http://www.journaldunet.com/developpeur/tutoriel/dht/070119-js-unobstrusive-javascript-non-intrusif.shtml

comment #62 On 07/12, fggfgfgf wrote :

gfgfgf

comment #63 On 07/12, fggfgfgf wrote :

gffgffgfgf

comment #64 On 20/12, dfgdfg wrote :

gdfgdfg

comment #65 On 27/12, Toto wrote :

tchoup tchoup

comment #66 On 13/02, fef wrote :

ffe

comment #67 On 15/02, fff wrote :

ff

comment #68 On 20/03, wrote :

un essai simple

comment #69 On 23/03, lolo wrote :

lolo

comment #70 On 13/04, qs wrote :

qsdqsd

comment #71 On 06/05, ede wrote :

dee

comment #72 On 06/05, test wrote :

test

comment #73 On 23/05, pseudo test wrote :

test

comment #74 On 27/05, test wrote :

test

comment #75 On 29/05, ghjghjh wrote :

k,ghjghjfghgjgj

comment #76 On 11/06, tertertertert wrote :

tertretertre

comment #77 On 11/06, tertertertert wrote :

rzzrrzzreezrzr

comment #78 On 14/06, ssq wrote :

test

comment #79 On 04/07, jlkhjkl wrote :

jlhjlkhjllk n,:;

comment #80 On 13/07, dvdvdv wrote :

dfdgdgddvdvdvddvdv

comment #81 On 16/08, wrote :

vrevbge

comment #82 On 16/08, plop wrote :

oueip pas mal

comment #83 On 08/09, hjghj wrote :

Blabla le test :)

comment #84 On 15/09, foezijfozijozifje wrote :

ezofijfezojzofeij

comment #85 On 16/09, nla wrote :

eyeyr

comment #86 On 05/10, Mike wrote :

intéressant

comment #87 On 11/10, sdfsdfdsfds wrote :

fdssdf

comment #88 On 12/10, Flo wrote :

nikel

comment #89 On 18/10, muska wrote :

merci pour le tuto

comment #90 On 02/11, cmoilinconnu68 wrote :

Testouille :)

comment #91 On 22/11, rtyurt wrote :

uyyu

comment #92 On 24/11, nico wrote :

merci pour le script ;-)

comment #93 On 14/12, a wrote :

a

comment #94 On 22/12, ww wrote :

blblalablbablabla

comment #95 On 26/12, moi wrote :

super

comment #96 On 31/12, lol wrote :

lol

comment #97 On 11/01, remay wrote :

test

comment #98 On 21/01, Julien wrote :

Pouet

comment #99 On 21/01, sideral wrote :

test

comment #100 On 21/01, sideral wrote :

Test essai

comment #101 On 28/01, test wrote :

test

comment #102 On 08/02, test wrote :

test

comment #103 On 10/02, qsd wrote :

qsdqsd

comment #104 On 10/02, qsd wrote :

qd

comment #105 On 17/02, test wrote :

salut

comment #106 On 23/02, Robert wrote :

Bla

comment #107 On 27/02, sgdgf wrote :

yrtetsets

comment #108 On 06/03, wrote :

Cool, ça marche

comment #109 On 26/03, dfgdf wrote :

fdgdg

comment #110 On 12/04, fb wrote :

stjhsdhjsdhjsdhjsdjhdt

comment #111 On 15/04, oups wrote :

énième test

sorry :-)

comment #112 On 15/04, sdfgh wrote :

test test :-)

comment #113 On 20/04, hghgfhghgf wrote :

ghhghhgf

comment #114 On 20/04, hghgfhghgf wrote :

fgdfgdgfd

comment #115 On 02/05, stephane wrote :

A la recherche d'un script comme celui-ci...

comment #116 On 12/05, jkhl wrote :

kjlkjhl

comment #117 On 14/05, dfdfgdf wrote :

fdffsddf

comment #118 On 19/05, jfjfj wrote :

ehfhf

comment #119 On 21/05, wrote :

dvbkjbsdks

ca al air bon

comment #120 On 22/05, test wrote :

test

comment #121 On 23/05, yo wrote :

superbe le script mais tu n'es pas un bon prof on comprend rien a ton installation !!!!

comment #122 On 30/05, test wrote :

test

comment #123 On 05/12, Yacoub wrote :

la classe!

comment #124 On 09/12, Test wrote :

Test avec Chrome

comment #125 On 12/12, testeur wrote :

test

comment #126 On 12/01, Nik0la wrote :

Sur Chrome.

comment #127 On 14/01, adrien wrote :

test

comment #128 On 26/01, Ben ça a l'air de marcher... Chouette! wrote :

Ben ça a l'air de marcher... Chouette!

comment #129 On 20/02, Ben wrote :

Voyons ça ...

comment #130 On 20/02, Ben wrote :

encore une fois

comment #131 On 19/03, camyo wrote :

je test le truc ...

comment #132 On 15/05, Paul wrote :

TEST

comment #133 On 22/05, Mwa wrote :

Je test :)

comment #134 On 27/05, gergergreg wrote :

gregergregreg

comment #135 On 05/06, danazik wrote :

mercii

comment #136 On 22/06, test wrote :

test

comment #137 On 22/06, test wrote :

test

comment #138 On 13/07, asdf wrote :

sdf

comment #139 On 13/07, gfhfh wrote :

ghfh

comment #140 On 25/07, niple wrote :

Teston ca

comment #141 On 16/09, heu wrote :

lol

comment #142 On 29/09, TEST wrote :

Test ;)

comment #143 On 04/11, oijoijojio wrote :

jiojoi

comment #144 On 13/11, alex wrote :

je test

comment #145 On 12/02, ttttt wrote :

test reponse

Technorati Profile