![]() Data is not directly found on the markup - This means that your markup is kept clean of any additional data, and only JavaScript sees it.Sometimes you just don't want to wait for the information, load the page, and have the information reach whenever. Allows for asynchronous data transfer - Getting the information from PHP might be time/resources expensive.Without mixing the two, you get more readable code on both languages. More readable - JavaScript is JavaScript, PHP is PHP.Better separation between layers - If tomorrow you stop using PHP, and want to move to a servlet, a REST API, or some other service, you don't have to change much of the JavaScript code.This method is considered the best, because your server side and client side scripts are completely separate. Use AJAX to get the data you need from the server In this post, we'll examine each of the above methods, and see the pros and cons of each, as well as how to implement them. Echo the data into the page somewhere, and use JavaScript to get the information from the DOM.Use AJAX to get the data you need from the server.Some require more overhead than others, and some are considered better than others. There are actually several approaches to do this. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |