Get support for garak/sfjqec
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
garak/sfjqec
sfjqec
(english version below)
Questo progetto symfony, basato su symfony 1.4 e Propel 1.5, è stato creato a scopo didattico, per una presentazione tenuta inizialmente per il PUG Roma e poi ampliata per il phpDay. Lo scopo di questo codice è in generale mostrare come integrare correttamente Javascript e PHP, con particolare riferimento a symfony e jQuery. Il progetto mostra un semplicissimo e-commerce, da cui il nome: sfjqec è formato da sf (symfony) + jq (jQuery) + ec (e-commerce).
in breve
In estrema sintesi, questo progetto mostra come integrare correttamente Javascript e PHP, usando AJAX. I passi sono i seguenti:
- scrivere l'applicazione come se Javascript non esistesse
- legare alcuni eventi (tipicamente click di link e submit di form) a delle funzioni Javascript
- ciascuna di queste funzioni Javascript richiama uno script PHP, tramite AJAX
- al successo della chiamata AJAX, richiama un'altra funzione Javascript, che si occupa di manipolare il DOM
Nello specifico di jQuery e symfony, i passi si traducono nel seguente modo:
- scrivere il controller normalmente
- scrivere un file Javascript che usi l'evento
ready()
di jQuery e che faccia ilbind
dei click e dei submit necessari - usare l'evento passato da
bind
nella funzione Javascript per estrarre i riferimenti necessari dal DOM - nel controller, effettuare le necessarie modifiche (spesso basta modificare i redirect, in modo che NON siano effettuati per le richieste AJAX)
- nella vista, aggiungere un file del tipo
NomeAzioneSuccess.json.php
- di nuovo nel file Javascript, scrivere la funzione che deve manipolare il DOM,
basandosi sulla variabile
result
, che a questo punto contiene un oggetto JSON, che jQuery ricava dal codice della vista del punto precedente
A questo punto il mio consiglio è quello di analizzare i passi precedenti, tenendo sott'occhio il codice di questo progetto, in particolare il controller e il file js.
english version
This symfony project, based on symfony 1.4 and Propel 1.5, has been created for learning purpose, for a presentation held a first time forPUG Roma and then, in a wider format, for phpDay. The purpose of this code is showing how to integrate in a proper way Javascript e PHP, with specific references to symfony and jQuery. The project shows a very simple e-commerce site, so it's called "sfjqec": sf (symfony) + jq (jQuery) + ec (e-commerce).
in short
The correct way to integrate Javascript and PHP, with AJAX, is divided in 4 steps:
- write app as if Javascript wouldn't exist
- tie some events (link clicks and form submits, tipically) to Javascript functions
- each of such functions recall a PHP script, via AJAX
- when AJAX call succeeds, Javascript calls another function, that deals with DOM manipulation
With jQuery and symfony, the steps are translated like follow:
- write a standard controller
- write a Javascript file using jQuery's
ready()
event, doing abind
of clicks and submits, where needed - use event passed by
bind
in Javascript function and extract needed references from DOM - in the controller, do the needed adaptations (often all you need is to change redirects, so they are NOT executed for AJAX requests)
- in the view, add a file like
ActionNameSuccess..json.php
- again in Javascript file, write a function to manipolate DOM, based on
result
variabile, that is currently containing a JSON object, elaborated by jQuery from the view
My advice is to analyze those steps, while looking to project code, mainly the controller and the js file.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2