I just found out that AJAX is soooo easy to use and soooo useful in web development. I think jQuery was a bomb and now this... what else am i losing here?
I started by searching tutorials on using API's with PHP and ended up learning AJAX for calling scripts without refreshing a page. I feel so bad for not learning this before... I think I won't use any
Code: Select all
<form action="register.php"> Code: Select all
<form action="login.php">I know there's hate on W3Schools, but it was there i learned the basics of AJAX, I recommend it not because it is good tutorial, but its the only one i read so i will assume it is a good one. Here it is : http://www.w3schools.com/ajax/.
So for those who don't know, AJAX stands for Async.. (long word) - Javascript And XML, that basically says that you can _POST and _GET the crap out of your scripts without a single page refresh, thus this being used in most web IM's i believe (Now that i talk about this, it would be a cool project to create one :O, I'm gonna try). So if you're tired of having your index full of redirects to another scripts and those scripts getting executed and then redirect back to your index, fear no more! AJAX is here!! (It was here for 10 years but.. IT IS HERE!!).
I won't give a tutorial on it, since.. well I just learned it, but so you can know how easy it is, you have your javascript script, and then inside of a single function you create a HTTPRequestObject (ActiveX on IE5 and IE6), and with that object you call whatever script you want with either GET or POST method, like this:
Code: Select all
xmlhttp.open("GET","getSomething.php?keyword="+str,true);On the other side (getSomething.php):
Code: Select all
$key = $_REQUEST["keyword"];
if($key == "date")
echo date(); // Spit the date!!
What are you still doing reading this? GO Learn it if you wanna be a web developer!! I think you will need it!