jQuery get() si post() sunt aplicatii ale metodei ajax().
$.get(url, data, success, dataType); $.post(url, data, success, dataType);- url - adresa URL la care este trimisa cererea.
<!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=un_id'; $.get('script.php', data, function(raspuns){ $('#dv').html(raspuns); }); }); }); --></script> </head> <body> <div id="dv">Aici va fi afisat raspunsul de la server.</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 = 'nume='+$('#nm').val(); $.post('script.php', data, function(raspuns){ $('#dv').html(raspuns); }); return false; // necesar ca sa nu deschida pagina cu adresa din formular cand e trimis }); }); --></script> </head> <body> <div id="dv">Aici va fi afisat raspunsul de la server.</div><br /> <form action="script.php" method="post"> Nume: <input type="text" name="nm" id="nm" /><br /> <input type="submit" value="Trimite" /> </form> </body> </html>Demo:
<object type="application/x-shockwave-flash" data="file.swf" width="500" height="250"> <param name="src" value="file.swf" /> Browser-ul dv. nu suporta SWF. </object>
input:focus { background-color: #88fe88; }
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}'; var obj = JSON.parse(jsnstr); alert(obj.url);
if (file_put_contents("file.txt", "content")) echo "Fisierul a fost creat"; else echo "Fisierul nu poate fi creat";
I planted the third tree. - Am plantat al treilea pom.
Yo planté el tercero árbol. - Am plantat al treilea pom.