What is Ajax ?
Ajax is a group of technologies which allows to send and retrieve data from the server without interfering with the display or behaviour of the existing page.Ajax(Asynchronus java-script +XML) uses HTML and CSS to combine and style the information.The DOM is accessed by JavaScript to dynamically display and allow the user to interact with the information presented.JavaScript and theXMLHttpRequest object provide a method of exchanging data between browser and server without full page reloads.
How to use ?
First you have to implement a JavaScript function as shown belowurl : have to specify the controller and the specific function
Type: Type of passing the data can be GET or POST
data: in this section you have to specify the the data which you want to pass to the back end.
Controller
Using $_GET[] method you can get the value which is passed from the JavaScript and use it in the back end.
Here what i have done is i aqured the post id and passed it to the model post.
Drawbacks
- In pre-HTML5 browsers, dynamically created pages using successive Ajax requests does not register im the browser's history, so clicking the browser's "back" button may not have returned the previous Ajax-enabled page,It will return to the last static page insted.
- Cannot be Bookmarked.
- Any browser which does not support JavaScript or XMLHttpRequest, will not be able to properly use pages which depends on Ajax.
- This kind of programming can lead to complex code that is hard to maintain, debug or to test.