PHP Classes

File: fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/ajax.js

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/ajax.js   Download  
File: fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/ajax.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/ajax.js
Date: 1 year ago
Size: 725 bytes
 

Contents

Class file image Download
// global variables to keep track of the request // and the function to call when done var ajaxreq=false, ajaxCallback; // ajaxRequest: Sets up a request function ajaxRequest(filename) { try { //make a new request object ajaxreq= new XMLHttpRequest(); } catch (error) { return false; } ajaxreq.open("GET", filename); ajaxreq.onreadystatechange = ajaxResponse; ajaxreq.send(null); } // ajaxResponse: Waits for response and calls a function function ajaxResponse() { if (ajaxreq.readyState !=4) return; if (ajaxreq.status==200) { // if the request succeeded... if (ajaxCallback) ajaxCallback(); } else alert("Request failed: " + ajaxreq.statusText); return true; }