A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Snippets Functions Classes
Home | PHP Resources | MySQL Zipbase | Forums
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP Code Snippets</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(URL){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong (User Probably Doesn't have JS or JS is turned off)
alert("You Browser Doesn't support AJAX.");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
//This if satement will check if the status of the script
//If the readyState is not equal to 4 (The request is complete)
//It will display text that says loading...
if(ajaxRequest.readyState < 4){
//AJAX in the prenthacies, is what id element in the body will be changed.
document.getElementById('AJAX').innerHTML = "<h2>Loading...</h2>";
}
//Once the readyState is equal to four, this means that the request was sent,
//and successfully processed.
if(ajaxRequest.readyState == 4){
//This is where the output of the file we called and it will be placed
//in the div where we named the ID = AJAX
document.getElementById('AJAX').innerHTML = ajaxRequest.responseText;
}
}
//This section processes the data
ajaxRequest.open("GET", URL, true);
ajaxRequest.send(null);
}
//-->
</script>
</head>
<body>
<!-- This is the link to the ajax function
It should always start with javascript:
after that is the function name ajaxFunction
inside the parenthacies, is the file we want,
this file can look like any URL you would make in a
normal href. Examples:
date.php
date.php?page=1
date.php?page=1&name=fred
-->
<a href="javascript:ajaxFunction('date.php')">What Time Is It?</a>
<div id="AJAX"></div>
</body>
<?php
$AntePost = date("A");
$time = date("g:i:s");
if($AntePost == "AM"){
echo 'Good Morning!';
}else{
echo 'Good Evening!';
}
?>
Suggested Difficulty Level: Intermediate
Current Score: 3.01
Total votes: 325
Total Views: 7166
Other top snippets by admin:
1. JPG to ASCII Converter
2. Add (th, st, nd, rd, th) to the end of a number
3. Dynamic Page Content From Links
4. Simple Image CAPTCHA
5. Logout Inactive User
1. Auth Class with (2.83 of 87)
2. Test Please Delete (2.83 of 30)
3. Return all repeated (3.64 of 72)
4. Convert an integer (3.3 of 71)
5. URL Shortening for (2.75 of 52)
6. Monthly Content Sorting (3 of 45)
7. Show String Trimmed (2.97 of 65)
8. Human readable file (2.01 of 70)
9. Randomize array values (2.8 of 82)
10. Create a recursive (3.35 of 55)
1. Parse RFC822 date (4 of 1)
2. Dynamic Image Uploading (5 of 1)
3. Spam Filter (0 of 0)
4. Is Multiple (0 of 0)
5. Base64 Encode / (0 of 0)
6. URL Encode / (0 of 0)
7. temp openbills (0 of 0)
8. Php Iban Validator (0 of 0)
9. Mysql Table Builder (0 of 0)
10. File size of (1.75 of 4)
11. Mail from your (1 of 1)
12. OddEven Class (0 of 0)
13. Detect if a (1 of 1)
14. MB CopyMCF-DIR :: (5 of 1)
15. Upper/Lower Case Accented (0 of 0)
16. Zodiac Signs (3 of 1)
17. Really useful code (2.5 of 2)
18. Calculate Central European (0 of 0)
19. Email Attachment (4 of 1)
20. ImageMagick Image Upload (0 of 0)
21. convert plain html (2 of 2)
22. Tag Builder (3.25 of 4)
23. Get Inserted ID (4.33 of 3)
24. Watermark An Image (3.33 of 3)
25. Check Prime Numbers (1.5 of 8)
2010-05-20 00:00:00