jQuery get() and post() are aplications of the ajax() method.
$.get(url, data, success, dataType); $.post(url, data, success, dataType);- url - specifies the url to send the request to.
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>jQuery Ajax - GET</title> <script type="text/javascript" src="jquery_1.6.1.js"></script> <script type="text/javascript"><!-- $(document).ready(function() { $('#buton').click(function() { var data = 'id=an_id'; $.get('script.php', data, function(response){ $('#dv').html(response); }); }); }); --></script> </head> <body> <div id="dv">Here will be displayed the response.</div><br /> <button id="buton">Click</button> </body> </html>Demo:
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>jQuery Ajax - POST</title> <script type="text/javascript" src="jquery_1.6.1.js"></script> <script type="text/javascript"><!-- $(document).ready(function() { $('form').submit(function() { var data = 'name='+$('#nm').val(); $.post('script.php', data, function(response){ $('#dv').html(response); }); return false; // required to not open the page when form is submited }); }); --></script> </head> <body> <div id="dv">Here will be displayed the response.</div><br /> <form action="script.php" method="post"> Name: <input type="text" name="nm" id="nm" /><br /> <input type="submit" value="Submit" /> </form> </body> </html>Demo:
<input type="date" name="set_date" value="2012-10-15" />
h2 { text-shadow: 2px 3px 3px #a0a1fe; }
var pags = ["lessons", "courses"]; pags.push("download", "tutorials"); alert(pags[2]); // download
$lang =[10=>"PHP", 20=>"JavaScript", "site"=>"coursesweb.net"); ksort($lang); var_export($lang); // array ("site"=>"coursesweb.net", 10=>"PHP", 20=>"JavaScript")