Jquery Sample


<!doctype html> <html> <title>Ajax example </title> <head> <style> body{ background:url('style/bgpic1.jpg'); } </style> </head> <body> <div align="center" id="wrapper"> <table border="3" width="800" height="240" > <tr><td valign="top"> <p><font color="grey">This is an example page for Jquery and Ajax</font></p> <!DOCTYPE html> <html> <head> <script language="JavaScript" type="text/javascript"> function ajax_post(){ // Create our XMLHttpRequest object var hr = new XMLHttpRequest(); // Create some variables we need to send to our PHP file var url = "ajaxtest1.php"; var fn = document.getElementById("first_name").value; var ln = document.getElementById("last_name").value; var vars = "firstname="+fn+"&lastname="+ln; hr.open("POST", url, true); // Set content type header information for sending url encoded variables in the request hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); /* Access the onreadystatechange event for the XMLHttpRequest object*/ hr.onreadystatechange = function() { if(hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("status").innerHTML = return_data; } } // Send the data to PHP now... and wait for response to update the status div hr.send(vars); // Actually execute the request document.getElementById("status").innerHTML = "One Moment..."; } </script> </head> <body> <p>This is an Ajax and PHP example</p> First Name: <input id="first_name" name="first_name" type="text" /> <br /><br /> Last Name: <input id="last_name" name="last_name" type="text" /> <br /><br /> <input name="myBtn" type="submit" value="Submit Data" onClick="javascript:ajax_post();"> <br /><br /> <div id="status"></div> </body> </html> </td></tr></table></div> <div id="pageFooter"><a href="http://www.draconmedia.com"> <li>Draconmedia,LLC.</a></li> </div> </div> </body> </html>

Jason is a custom website developer and graphic designer with extensive experience in computer software scripting, computer animation, and customer service. His current focus on creating websites and creating e-commerce stores is preceded by 10 + years in software development, and eight years in the U.S. Navy.

Sample Codes







Contact Details
News Letters