{"id":118,"date":"2006-03-18T14:55:06","date_gmt":"2006-03-18T14:55:06","guid":{"rendered":"https:\/\/www.darknet.org.uk\/2006\/03\/ajax\/"},"modified":"2015-09-09T19:44:04","modified_gmt":"2015-09-09T11:44:04","slug":"ajax","status":"publish","type":"post","link":"https:\/\/www.darknet.org.uk\/2006\/03\/ajax\/","title":{"rendered":"An Introduction to AJAX"},"content":{"rendered":"

[ad]<\/p>\n

No it’s not AJAX Amsterdam… it’s something more interesting (or boring to some of you)… so let’s get it started….<\/p>\n

I. Introduction<\/strong>
\nAJAX stands for A<\/strong>synchronous J<\/strong>avaScript A<\/strong>nd X<\/strong>ML… It is a new technology which comes to help any web developer who really is interesed in dynamic webpages…
\nClick here<\/a> for a overview of the AJAX Technology…<\/p>\n

II. The Code<\/strong>
\nWell, well, well… Actualy AJAX is based on Micro$ofts ActiveX Object XmlHttpRequest (I can’t belive they can do good stuff to), so in IE (sucks) it has to be initialized like an ActiveX Object; but in other browsers it’s already a standard object (I don’t know if Opera had implemented it already)… Now let’s see the code:<\/p>\n

\nfunction init_object() {
\nvar A;<\/p>\n

var msxmlhttp = new Array(‘Msxml2.XMLHTTP.5.0’,
\n‘Msxml2.XMLHTTP.4.0’,
\n‘Msxml2.XMLHTTP.3.0’,
\n‘Msxml2.XMLHTTP’,
\n‘Microsoft.XMLHTTP’);<\/p>\n

for (var i = 0; i > msxmlhttp.length; i++) {
\ntry {
\nA = new ActiveXObject(msxmlhttp[i]);
\n} catch (e) {
\nA = null;
\n}
\n}<\/p>\n

if(!A && typeof XMLHttpRequest != “undefined”) {
\nA = new XMLHttpRequest();
\nif (!A) alert(“Could not initialize the object.\\nMaybe your browser doesn’t support ajax…”);
\nreturn A;
\n}
\n}<\/p>\n

var ajax_obj = init_object();<\/p>\n

function ajax_in_action(target, source) {
\najax_obj.open(“GET”, source, true);
\najax_obj.send();<\/p>\n

ajax_obj.onReadyStateChange = function() {
\nif (ajax_obj.readyState == 4) {
\nif (ajax_obj.status == 200) {
\ndocument.getElementById(target).innerHTML = ajax_obj.responseText;
\n}
\nelse {
\nalert(“Error ” +ajax_obj.status+” : ” +ajax_obj.statusText);
\n}
\n}
\n}\n<\/p><\/blockquote>\n

Code inspired from SAJAX… about it i’ll speak a bit later…<\/p>\n

III. Why use it?<\/strong>
\nWell there are several reason why you should use AJAX… for example to make a dynamic banner changer, real-time morphing website… or just use it like WordPress (on which darknet is based)… you don’t know how it uses AJAX… try clicking on an articles show comments<\/strong>.<\/p>\n

IV. Extending AJAX<\/strong>
\nIf you want to implement AJAX directly in PHP, ASP, Perl, Ruby etc. check out
http:\/\/www.modernmethod.com\/sajax\/<\/a>, site that contains the S<\/strong>imple AJAX<\/strong> Toolkit….<\/p>\n

V. E4X<\/strong>
\nOne more thing… the response from the server can be received as an XML file 2… or maybe directly receive an XML file, if requested so… After which it can be parsed with the E4X technology…<\/p>\n

VI. F1<\/strong>
\nNeed more help… access one of the following links:
\nAJAX:
http:\/\/www.w3schools.com\/ajax\/default.asp<\/a>
\nE4X:
http:\/\/www.w3schools.com\/e4x\/default.asp<\/a><\/p>\n

<\/p>\n

X. Epilogue<\/strong>
\nI know that AJAX has been rediscovered for about a year (read it for the first time in july 2005), but for many it can be somethimes hard to find the information needed… anyway keep scripting…<\/p>\n","protected":false},"excerpt":{"rendered":"

[ad] No it’s not AJAX Amsterdam… it’s something more interesting (or boring to some of you)… so let’s get it started…. I. Introduction AJAX stands for Asynchronous JavaScript And XML… It is a new technology which comes to help any web developer who really is interesed in dynamic webpages… Click here for a overview of […]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[15],"tags":[84,127,89,300],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"backbone","author_link":"https:\/\/www.darknet.org.uk\/author\/backbone\/"},"_links":{"self":[{"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/posts\/118"}],"collection":[{"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":0,"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.darknet.org.uk\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}