Hello.

I need to use a lot of ajax, I want to use oop. But here is the problem: how to call a function in a class from under ajax?

  • Those. to make a separate file that will accept ajax requests and, depending on the parameter, run the function? - GlavPox
  • We are talking about OOP? Separate files to OOP has nothing to do. - zb '
  • one
    > But here is the problem: how to call a function in a class from under ajax? Add a url parser, which will convert requests of the type host.org/magic/index to try {// in general there is a little different protection should be $ params = $ _GET; $ controller = new MagicController (); $ response = call_user_func_array (array ($ controller, 'index'), $ params); } or add a router in which the rules of such transformations will be hard-coded. The most sensible will be to organize rest api - there is a resource at / resource, a get request receives data, post - updates, etc. - etki

0