Using AJAX with a PHP Front Controller

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a framework that uses the front controller design pattern for a
single point of entry to the application and the autoload function for
includes. I am trying to incorporate AJAX into the framework, but the
javascript calls to php ignore my front controller code when
instantiating classes.

Can someone please provide me with some hints on how I can make this
work? Thank you.

Re: Using AJAX with a PHP Front Controller

Aquaren wrote:

Quoted text here. Click to load it


Hard to say without knowing what your frontcontroller does, BUT the  
bottomline is this: When you let JavaScript instantiate a XMLHTTPRequest  
(or whatever it is called in different browsers), you feed it the url,  
check what your app returns.
Just make an alert in your JS with that url, and type that into a browser.
(Or when it is long, use prompt, so you can copy/paste it)

What does your application return?

PHP doesn't care if the XMLHTTPRequest makes a request, or somebody visits  
your page 'normal'.  
PHP just runs its script and produces the output.

So just debug your AJAX (and/or PHP) via direct calls to the url in your  

PS: In case you use cookies / sessions: The XMLHTTPRequest DOES send the  
cookie(s) the same way as a direct invocation via a browser would do. So  
that should work alright.

Erwin Moller

Site Timeline