File: ajaxCon.example.php

Recommend this page to a friend!
  Classes of Matthew Knowlton   ajaxCon   ajaxCon.example.php   Download  
File: ajaxCon.example.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: ajaxCon
Send asynchronous AJAX requests to a server
Author: By
Last change: modified presets array
Date: 9 years ago
Size: 1,596 bytes


Class file image Download
<?php require_once('ajaxCon.class.php'); $accountsRegistered = array( '', '', '', ); $ajaxCon->addModule('CheckEmail', function($params) use ($accountsRegistered){ $email = strtolower($params['Email']); if(filter_var($email, FILTER_VALIDATE_EMAIL) == false) return array('valid' => false); if(in_array($email, $accountsRegistered)) return array('valid' => true, 'hasAccount' => true); return array('valid' => true, 'hasAccount' => false); }); ?> <html> <head> <script src=""></script> <script src="ajaxCon.class.js"></script> <script> $(document).ready(function(){ $('button').click(function(){ Email = $('#Email').val();'CheckEmail', {'Email':Email}, function(r){ if(r.return.valid == false) return $('#EmailStatus').text('Input was not a valid email.'); if(r.return.hasAccount == true) return $('#EmailStatus').text('This email is already registered.'); return $('#EmailStatus').text('Success! The email address is not in our system.'); }); }); }); </script> </head> <body> <p>Email Address Checker Example</p> <input id="Email"/><button>Check</button> <div id="EmailStatus"></div> <br/> <i>Note: and are already "registered" in the system</i> </body> </html>