PHP, HTML, jQuery website file- and code structure -


i'm quite new web developement , i'm working on school project create simple educational video platform. upcomming task make site single page application. i've gathered, jquery , ajax make happen. while browsing examples , tutorials these languages, i'm starting wonder if html/php/script code structure needs change. picture contains typical structure of files. enter image description here

i've been writing php , html in same .php file each job site has (e.g. upload video form data). i've included of these in main.php file. make single page application, will need separate html , php each include file, different files? i'd feedback (opinions) on how i've structured far.

the high-level of want move php logic out of html files. here's how single-page app should handle data flow:

  1. in file.html: forms , fields take user input (anything text files)
  2. in file.js: use jquery listen events happening, using page's dom elements pass dynamically entered data server through ajax calls
  3. in controller.php: ajax call goes method in 1 of controller files logic happen, items added database, etc.
  4. in file.js: ajax call finishes receiving data controller method, , makes necessary changes view file (again using jquery)
  5. in file.html: jquery updates show user results of input

the big change make separating php , html files. since you're doing single-page application, can away 1 html file, should have have controller every class (assuming using class , model interchangeably).

one thing might missing routes, though i've seen people getting passing files 'url' field (a required field when making ajax call).

as far file structure, web frameworks pair cs , js folders parent folder called public.

when comes jquery, best cheat sheet around. make sure have @ least basic understanding of dom before going in deep though.


Comments