Making ajax requests inside a Zend project is easy. And if you want to make sure that a user without enabled javascript should be able to see the content there is no problem. In the following article there is a nice way to use ajax calls to our Zend pages without worries.
The current article just a simple black application including Zend and loading Doctrine 1.2.4. Actually I created this to exist in my code library, just in case I will need this again and I thought it maybe useful for someone else.
Posted: 7 July 2012
Tags:
PHP
Sometimes we use some techniques, just because we are used to them, without always been the best practices. Take for the example the arrays and the way we iterate through their values. Usually, the arrays that we manipulate are pretty small(some Kb maybe). So we do a foreach and everything works as expected. However this is not always the case.
In this article, I want to show to anyone unfamiliar with Jquery and Ajax how easy is to push dynamically content to our web page without page refreshing. Before going any further, I have to mention something important. The following code, is full with bad programmming techniques. It is not object oriented, it does not follow the MVC architecture and it is unsafe (bad passwords, no data filtering e.t.c). I made it that way to shrink the code as much as I could, to make my point clearer. With 5 lines of Jquery we can do miracles. It is really a 'write less, do more' library!
I wrote a few lines of code, that are useful to avoid dublicate form submission, because user has refreshed a page and the form data are resent. I have used PHP because this is the language that I prefer to code, but the logic is very simple and it can be easily implemented in Java or Asp.