PDA

View Full Version : Ok, so I'm a n00b. MVC and PHP backend problems



novadys-sbu
30 Nov 2012, 1:54 AM
Hello everyone,

As usual there is probably a simple answer to my problems, but I've been going around in circles.
Here goes :

I have a view in ExtJs with a simple button. In the handler function, I would like to call a function from my PHP backend (DocumentController.php class).


Now, I absolutely need to call a PHP function as I wish to download a document on the click of the button.
So what do I need to do in my handler function to call an DocumentController object ? Or do I have to call a plain PHP 4 page ?

Is there an equivalent to :
DocumentController myController = new DocumentController();
myController.downloadDocument();

Thanks for your help :)

existdissolve
1 Dec 2012, 2:02 PM
The easiest and quickest way to return results to your ExtJS app is to make an AJAX request to a remotely-accessible url in your PHP app that is configured to return data in a format that ExtJS can make use of (e.g., JSON, XML, etc.).

For downloading files, you'll probably want to simply open up a new window with a url to a page in your PHP app that can manage serving up the file with the appropriate headers, content type, etc.