1. Load gets static files from the server
<id= "ResText"></div>
function (ResponseText, Textstatus, XMLHttpRequest) { // codehere})
2. Get
$.get (URL [, data] [, callback] [, type]) { //// / data = {a:1, ...} // callback automatically passes the request result and status to the method // type:xml, HTML, script, JSON, text, _default}
2.1 HTML
$ (function() { $ (' #send '). Click (function() { $.get (' get.php '), {username:$ (' #username '). Val ()}, function (data, Textstatus) { $ (' #resText '). HTML (data); });});
2.2 XML
$ (function() { $ (' #send '). Click (function() { $.get (' get.php ', {}, function(data, textstatus) { var username = $ (data). Find (' comment '). attr (' username ' ) ); // ... }); ' XML ');});
2.3 JSON (JSON format must be strict and all attributes should be enclosed in double quotes.)
$ (function() { $ (' #send '). Click (function() { $.get (' get.php ', {}, function(data, textstatus) { var username = data.username; }); },' JSON ');});
3. $.getjson
$ (function() { $.getjson (function(data) { $ (' #resText '). empty (); Empty content var html = '; function (Index, item) { var username = item.username; } );});
4. $.ajax (Options)
$.ajax ({ type:' GET ', ' test.php ', ' json ', function (data) { function(index, item) { var user = item.username; }) ; }});