I'm not sure I understand the role of jQuery/JavaScript in MVC. I've found an article about it on A List Apart, but it doesn't clear anything up for me.

Does it bridge the communication between the View and the Controller, or does it do something else?

  • 1
    Umm javascript runs on the browser and is not directly related to the server-side MVC.. javascript itself can be structured like MVC with frameworks like backbone.js or javascriptMVC – Esailija Nov 21 '11 at 13:29

Javascript is not related to the zend framework, or anything you use on the server. It runs in the browser. (Yes it could run anywhere but let's simplify)

Let's say you have a desktop application that is programmed using the MVC pattern and at some point it needs to make a request to a server to fetch some data. To fulfill the request, the server might be using MVC pattern or it might not, it doesn't relate in any way to the desktop application.

Javascript works the same way but traditionally is more dependent on making requests to a web server than a desktop application. But it doesn't have to be, with html5 offline capabilities, file reading and localstorage you can make a desktop style javascript app that doesn't use any server at all but still runs in the browser. Now, you could design the javascript app using MVC or whatever you see fit but it doesn't relate to what any server you might be making requests to is using.

So to answer your question, there is no role for javascript in zend MVC. The zend MVC controller is only invoked by HTTP requests, while if you were to use MVC in javascript, the controller in javascript MVC would be invoked by various user actions in the app. And jQuery is just a bunch of javascript, so it applies for jQuery as well.


Your question contains a mismatch of two different levels of abstraction. MVC is a design pattern. JavaScript is a language, and libraries like jQuery are written in that language.

You might ask, what is the role of English in the telling of jokes? Jokes can happen in any language. English is one language in which a joke could be implemented.

Classic web MVC is a server-side thing and display-level technologies like JavaScript are part of the "View" layer, but there are also MVC frameworks that operate entirely on the client, entirely in JavaScript.

  • I have realized that after your and Esailija's answer. Thank you! – Rene Nov 23 '11 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.