Load from the Server-Ajax

The first is to keep the templates remote and use an XMLHttpRequest object to retrieve
additional markup. This approach is more convenient for single-page applications than
for multiple-page applications.

For instance, clicking on a link that should bring up a
new dialog box might look like this:

function loadDialog(name, oncomplete) {
var xhr = new XMLHttpRequest();
xhr.open("get", "/js/dialog/" + name, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var div = document.getElementById("dlg-holder");
div.innerHTML = xhr.responseText;
oncomplete();
} else {
// handle error
}
};
xhr.send(null);
}
Related Posts:
  • What is triggers? A trigger is a database object which is associated with particular database table. Triggers gets called automatically when particular event(INSERT, UPDATE, DELETE) occurs on table. … Read More
  • What line should you add to the Apache configuration file to ensure that the .php extension is recognized? This line ensures that Apache will treat files ending with the .php extension asPHP scripts:AddType application/x-httpd-php .php … Read More
  • What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()? mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array. mysql_fetch_object() -> Fetch a result row as an object. mysql_fetch_row() -> Fetch a result set as a regular array… Read More
  • php.ini Basics After you have compiled or installed PHP, you can still change its behavior with the php.ini file. On Linux/UNIX systems, the default location for this file is /usr/local/php/lib or the lib subdirectory of the PHP installati… Read More
  • How to prevent hijacking in PHP?  Make Error_reporting to E_ALL so that all variables will be intialized before using them. Make practice of using htmlentities(), strip_tags(), utf8_decode() and addslashes() for filtering malicious data in php&nb… Read More
  • Web server compression? The best way to understand web server compression is to think of sending ZIP filesinstead of uncompressed files from your web server to your web user. Sending less dataover the network will minimize network latency and your … Read More
  • $_ENV and $_SERVER ? PHP sets several variables for you containing information about the server, the environment, and your visitor's request. These are stored in the superglobal arrays $_ENV and $_SERVER, but their availability depends on whe… Read More
  • How register the variables into a session? session_register ($session_var) function. (adsbygoogle = window.adsbygoogle || []).push({}); … Read More
  • What Is a Session? It is stored at server side because PHP is server side scripting language Session is stored on server side because how much time page will execute it doesn't depend on client it depends on server. Server decide the sess… Read More
  • XMLHttpRequest-Ajax To do this, you must understand the three ways of creating an XMLHttpRequest object• IE 5: request = new ActiveXObject("Microsoft.XMLHTTP")• IE 6+: request = new ActiveXObject("Msxml2.XMLHTTP")• All others: request = new XML… Read More
  • Testing Ajax Event Handlers using Jasmine Spies JavaScript has several methods that execute asynchronously, such as setTimeout(), Ajax calls, as well as event-driven processes. These examples all have to wait until the current execution thread comes to an end and surre… Read More
  • magic_quotes_gpc, magic_quotes_runtime Magic quotes is the name of a PHP feature that automatically quotes inputdata, by using the addslashes() function. Historically, this was used so thatform data could be used directly in SQL queries without any security or qu… Read More
  • Ajax code   The keystone of AJAX is the XMLHttpRequest object. Different browsers use different methods to create the XMLHttpRequest object. Internet Explorer uses an ActiveXObject, while other browsers uses the built-in Ja… Read More
  • AJAX is Based on Web Standards AJAX stands for Asynchronous JavaScript And XML. AJAX is a type of programming made popular in 2005 by Google (with Google Suggest). AJAX is not a new programming language, but a new way to use existing standards. Wi… Read More
  • Validate a Text Field No web developers want their Ajax applications to hit the network with requests if the users leave necessary text fields blank. Thus, checking that input elements of type text and the large boxes called textareas in … Read More