Probably the wrong place to post this, and if so I apologize. I’m just trying to get a handle on what AJAX is, what it could do for me, and based on my current skills the bast way to learn about it. On that last point, I’ve maintained some huge and yet very primitive websites. But it started way back at a time when scripting was a nightmare. I think i got in right around the time Netscape 4 and IE 4 were the predominate browsers, and each version was taking their DOMs in significantly different directions. Building a library was almost futile, because each new browser version would break your interface to the DOM. For example, below was a test example I wrote for a long gone employer to demonstrate how a human-machine interface (HMI) for an electric substation could be done using a browser rather than a custom graphics application.
[url]http://elfintechnologies.com/html_hmi/hmi_tst1.htm
Unfortunately if you look at this in anything but IE, it won’t do anything anymore. In fact I’m shocked it still works in IE! Now this was just a demo to prove that screen control and display features could be altered without re-loading entire pages. But it still had no server side feeds. The data changing you see is just random number generators. Had my employer had any interest, my only prospect for server side communication would have been to write a JAVA applet, using something called a shared byte array object to exchange data with a server. Then, since Java can interact with javascript variables, I’d be able to complete the connection. The whole thing seemed like a daunting task.
So lately, as I’ve joined the ranks of the unemployed again, I’m trying to sharpen my skills, and I’ve seen AJAX come up again and again in employer requirements. And looking further, it SEEMS (big word) that AJAX might be a solution to such server to browser interaction, with methods I would NOT have to write or invent from scratch. Further, I get the impression that AJAX is both a javascript based methodology, and that in modern browsers, the DOMs have at least become sufficiently unified so that compatibility is much less a problem than it once was.
But maybe I have a totally wrong idea what AJAX is about, and maybe its completely the wrong tool for writing such HMIs? I am been more of an electronics and embedded systems engineer for the past decade, and I’ve obviously completely lost touch with web technology. So all pointers and advise is much appreciated.
I'll give my take on AJAX. I have developed numerous PC apps that interface with databases and create numerous reports. One problem is they only run on the PC not Macs, tables or other devices and they have to be installed and updated. I was looking to see if I could duplicate the app behavior using HTML5, CSS3, Javascript, jQuery, AJAX and PHP. I did not want numerous HTML pages. I wanted one HTML page and all the data to be update using AJAX. I was able to achieve almost identical behavior to the PC app. jQuery has made AJAX simple to do. AJAX is asynchronous. You need to figure out how to handle this. For example, I had numerous form items I needed to initialize from the database so I issued numerous AJAX requests. The order the data returned is not predictable. What I ended up doing is to write a recursive AJAX function so the requests happen sequentially. I even use AJAX to create the Word and PDF reports. I send an AJAX request to the server. The server creates the report and the AJAX request returns links to the reports. So in my experience AJAX helps you duplicate the typical desktop app experience.[/QUOTE]
There is no need to use timestamps. When AJAX returns the first result I process it and then call the same AJAX routine again using the next item I need. It is really simple. This is an intranet app for a small company. I do use SQL. Since the desktop app uses Access I still use the same Access db. I use PHP and connect using ODBC. So far it works reliably and fast. I may switch to SQL Server if I have problems. The hardest part of this was figuring out how to write Javascript in an object oriented way. I am new to Javascript. I basically created a 'class' to navigate each table. Lookup a book called Object-Oriented Javascript. Very helpful.[/QUOTE]
[CODE]
NavDb.prototype.getSelData = function () {
var cs, fmField, value, sql, cnt, csv,
$this = this;
cs = this.curSelector;
cnt = this.selectors.length;
if (cs >= cnt) { // check if done
$("#status").html("Initialization complete");
$("body").css("cursor", "default")
return;
}
$.ajax({
url: 'php/select.php',
type: 'POST',
context: this, // Only needed 'this' not this.parentNode.
dataType: 'json',
data: {
'sql': sql
}
}).done(function (data) {
if (data.success) {
if (data.v.length > 0) {
//process data
}
this.curSelector++;
this.getSelData(); // recursive call
}).fail(function (XHR, textStatus, errorThrown) {
$("#status").html(getErrorText(XHR.responseText));
$("body").css("cursor", "default")
})
}
};
[/CODE]
Maybe I am not explaining it correctly. I recursively call the function that performs the AJAX request. Here is a simplified version of the code.
[CODE]
[/QUOTE]
NavDb.prototype.getSelData = function () {
var cs, fmField, value, sql, cnt, csv,
$this = this;
cs = this.curSelector;
cnt = this.selectors.length;
if (cs >= cnt) { // check if done
$("#status").html("Initialization complete");
$("body").css("cursor", "default")
return;
}
$.ajax({
url: 'php/select.php',
type: 'POST',
context: this, // Only needed 'this' not this.parentNode.
dataType: 'json',
data: {
'sql': sql
}
}).done(function (data) {
if (data.success) {
if (data.v.length > 0) {
//process data
}
this.curSelector++;
this.getSelData(); // recursive call
}).fail(function (XHR, textStatus, errorThrown) {
$("#status").html(getErrorText(XHR.responseText));
$("body").css("cursor", "default")
})
}
};
[/CODE]
[CODE]if(typeof XMLHttpRequest!='function'){
XMLHttpRequest = function(){
try{ return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
try{ return window.createRequest();}catch(e){}
return false;
}
}
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET","script.php",true);
xmlHttp.onreadystatechange = function(){ if(xmlHttp.status==200 && xmlHttp.readystate==4) eval(xmlHttp.responseText);}
xmlHttp.send(null);
[/CODE]
I'll give my take on AJAX. I have developed numerous PC apps that interface with databases and create numerous reports. One problem is they only run on the PC not Macs, tables or other devices and they have to be installed and updated. I was looking to see if I could duplicate the app behavior using HTML5, CSS3, Javascript, jQuery, AJAX and PHP. I did not want numerous HTML pages. I wanted one HTML page and all the data to be update using AJAX. I was able to achieve almost identical behavior to the PC app. jQuery has made AJAX simple to do. AJAX is asynchronous. You need to figure out how to handle this. For example, I had numerous form items I needed to initialize from the database so I issued numerous AJAX requests. The order the data returned is not predictable. What I ended up doing is to write a recursive AJAX function so the requests happen sequentially. I even use AJAX to create the Word and PDF reports. I send an AJAX request to the server. The server creates the report and the AJAX request returns links to the reports. So in my experience AJAX helps you duplicate the typical desktop app experience.[/QUOTE]
Ok... very rough example of an ajax routine to work around browsers without XMLHttpRequest() as a built in function, the create a request module and the return being something that needs to be run as it may be a script, maybe... Total of 12 lines of code Vs JQuery with something like 30 lines of code.
[CODE]if(typeof XMLHttpRequest!='function'){
XMLHttpRequest = function(){
try{ return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
try{ return window.createRequest();}catch(e){}
return false;
}
}
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET","script.php",true);
xmlHttp.onreadystatechange = function(){ if(xmlHttp.status==200 && xmlHttp.readystate==4) eval(xmlHttp.responseText);}
xmlHttp.send(null);
[url=http://youtu.be/aS63PI1SX3g]شركة تنظيف منازل بالرياض[/url]
[url=http://aladelgroup.wordpress.com/]شركة نظافة بالرياض[/url]
[url=http://youtu.be/4VIERvCpR4Y]تسليك مجارى[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D8%B4%D9%82%D9%82-0566724802/]تنظيف شقق بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%85%D9%88%D9%83%D9%8A%D8%AA-0566724802/]تنظيف موكيت بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%85%D8%AC%D8%A7%D9%84%D8%B3-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0566724802-%D8%B4%D8%B1%D9%83%D8%A9-%D8%A7%D9%84%D8%B9%D8%A7%D8%AF%D9%84/]تنظيف مجالس بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%A7%D9%84%D9%86%D8%B8%D8%A7%D9%81%D8%A9-%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9-0566724802/]شركة تنظيف بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D8%B3%D9%84%D9%8A%D9%83-%D9%85%D8%AC%D8%A7%D8%B1%D9%8A-0566724802/]شركة تسليك المجارى بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D9%86%D9%82%D9%84-%D8%A7%D8%AB%D8%A7%D8%AB-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0566724802/]شركة نقل اثاث بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D9%85%D9%83%D8%A7%D9%81%D8%AD%D8%A9-%D8%AD%D8%B4%D8%B1%D8%A7%D8%AA-0566724802/]شركة مكافحة حشرات بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D8%A7%D9%84%D8%A8%D9%8A%D9%88%D8%AA-0566724802-%D8%B4%D8%B1%D9%83%D8%A9-%D8%A7%D9%84%D8%B9%D8%A7%D8%AF%D9%84/]تنظيف بيوت بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D8%AE%D8%B2%D8%A7%D9%86%D8%A7%D8%AA-0566724802-%D8%B4%D8%B1%D9%83%D8%A9-%D8%A7%D9%84%D8%B9%D8%A7%D8%AF%D9%84/]تنظيف خزانات بالرياض[/url]
[url=http://aladelgroup.wordpress.com/%D8%B9%D8%B2%D9%84-%D8%AE%D8%B2%D8%A7%D9%86%D8%A7%D8%AA-0566724802-%D8%B9%D8%B2%D9%84-%D8%A7%D8%B3%D8%B7%D8%AD-0566724802-%D8%B4%D8%B1%D9%83%D8%A9-%D8%A7%D9%84%D8%B9%D8%A7%D8%AF%D9%84/]شركة عزل اسطح بالرياض[/url]
[url=http://ar.wikipedia.org/wiki/%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:%D9%86%D9%82%D9%84_%D8%A7%D8%AB%D8%A7%D8%AB_%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6_0566724802]شركة نقل اثاث بالرياض[/url]
[url=http://ar.wikipedia.org/wiki/%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:%D8%AA%D9%86%D8%B8%D9%8A%D9%81_%D8%A8%D9%8A%D9%88%D8%AA_%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6_0566724802]تنظيف بيوت بالرياض[/url]
[url=http://www.youtube.com/watch?v=UIeADoEipPw&feature=youtu.be]شركة تنظيف واجهات حجرية بالرياض[/url]
[url=http://www.youtube.com/watch?v=l5dejG9nr14&feature=youtu.be]شركة كشف تسربات المياه بالرياض[/url]
[url=http://www.youtube.com/watch?v=4US3PWjM__M]شركة تخزين اثاث بالرياض[/url]
[url=http://www.youtube.com/watch?v=DQiUX6Z-WT0&feature=youtu.be]نقل اثاث[/url]
[url=http://www.youtube.com/watch?v=Miv6AHE8yr0&feature=youtu.be]شركة تنظيف فلل بالرياض[/url]
[url=http://www.youtube.com/watch?v=qKS6eWOB8Sg]شركة تخزين عفش بالرياض[/url]
[url=http://www.youtube.com/watch?v=HmYPfv60r5o&feature=youtu.be]شركة نقل عفش بالرياض[/url]
[url=http://www.youtube.com/watch?v=CIGTriI31bA&feature=youtu.be]شركة تنظيف موكيت بالرياض[/url]
[url=http://www.youtube.com/watch?v=_8qU5EciSJo&feature=youtu.be]شركة تنظيف مجالس بالرياض[/url]
[url=http://www.youtube.com/watch?v=YbdbCKxRo90]شركة تنظيف شقق بالرياض[/url]
[url=http://www.youtube.com/watch?v=I4nHssNgcM8&feature=youtu.be]شركة تنظيف بيوت بالرياض[/url]
[url=http://www.youtube.com/watch?v=O5rf1t_PqHc]شركة تنظيف بيارات بالرياض[/url]
[url=http://www.youtube.com/watch?v=-A3Z0MMaHqo&feature=youtu.be]شركة رش مبيدات بالرياض[/url]
[url=http://www.youtube.com/watch?v=UPL0jHzYuzY&feature=youtu.be]شركة مكافحة حشرات بالرياض[/url]
[url=http://www.youtube.com/watch?v=GgA0NVaLEtc&feature=youtu.be]شركة عزل خزانات بالرياض[/url]
[url=http://www.youtube.com/watch?v=nosFKRcTja0&feature=youtu.be]شركة عزل اسطح بالرياض[/url]
[url=http://www.youtube.com/watch?v=Jek9W0Ft5a8]شركة تنظيف خزانات بالرياض[/url]
[url=http://www.youtube.com/watch?v=T0aFAwSqZeU]شركة تنظيف واجهات زجاج بالرياض[/url]
[url=http://youtu.be/qtrgUlrmmF0]شركة نقل اثاث بالرياض[/url]
[url=http://www.youtube.com/watch?v=uA-ruQfCULw&feature=youtu.be]شركة ترميمات عامة بالرياض[/url]
[url=http://www.dailymotion.com/video/x18rzcg_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%88%D8%A7%D8%AC%D9%87%D8%A7%D8%AA-%D8%AD%D8%AC%D8%B1%D9%8A%D8%A9-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف واجهات حجرية بالرياض[/url]
[url=http://www.dailymotion.com/video/x18t17a_%D8%B4%D8%B1%D9%83%D8%A9-%D9%83%D8%B4%D9%81-%D8%AA%D8%B3%D8%B1%D8%A8%D8%A7%D8%AA-%D8%A7%D9%84%D9%85%D9%8A%D8%A7%D9%87-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة كشف تسربات المياه بالرياض[/url]
[url=http://www.dailymotion.com/video/x18t99i_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D8%AE%D8%B2%D9%8A%D9%86-%D8%A7%D9%84%D8%A7%D8%AB%D8%A7%D8%AB-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تخزين عفش بالرياض[/url]
[url=http://www.dailymotion.com/video/x18t9ur_%D9%86%D9%82%D9%84-%D8%A7%D8%AB%D8%A7%D8%AB-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة نقل اثاث بالرياض[/url]
[url=http://www.dailymotion.com/video/x18rz4c_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%81%D9%84%D9%84-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف فلل بالرياض[/url]
[url=http://www.dailymotion.com/video/x18t8sp_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D8%AE%D8%B2%D9%8A%D9%86-%D8%A7%D9%84%D8%B9%D9%81%D8%B4-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تخزين عفش بالرياض[/url]
[url=http://www.dailymotion.com/video/x18s01z_%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%B9%D9%81%D8%B4-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة نقل عفش بالرياض[/url]
[url=http://www.dailymotion.com/video/x18rzad_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%85%D9%88%D9%83%D9%8A%D8%AA-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف موكيت بالرياض[/url]
[url=http://www.dailymotion.com/video/x18rz6t_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D9%85%D8%AC%D8%A7%D9%84%D8%B3-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف مجالس بالرياض[/url]
[url=http://www.dailymotion.com/video/x18ryn9_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D8%B4%D9%82%D9%82-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف شقق بالرياض[/url]
[url=http://www.dailymotion.com/video/x18ry80_%D8%B4%D8%B1%D9%83%D8%A9-%D8%AA%D9%86%D8%B8%D9%8A%D9%81-%D8%A8%D9%8A%D9%88%D8%AA-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6-0540736424-%D9%82%D9%85%D8%A9-%D8%A7%D9%84%D8%A7%D9%86%D8%AC%D8%A7%D8%B2-0566884259_webcam]شركة تنظيف بيوت بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/cleaninghaher]شركة تنظيف واجهات حجرية بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/tasrbatmiao]شركة كشف تسربات المياه بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/takzeenasas]شركة تخزين اثاث بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/alalsas]شركة نقل اثاث بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/cleaning-vellal]شركة تنظيف فلل بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/takzenalafesh]شركة تخزين عفش بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/kemaengaz1]شركة نقل عفش بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/moketkcleaning]شركة تنظيف موكيت بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/magals]شركة تنظيف مجالس بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/superceaning]شركة تنظيف شقق بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/housecleaning]شركة تنظيف بيوت بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/cleaningbiarat]شركة تنظيف بيارات بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/rashmobidat]شركة رش مبيدات بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/hashrat]شركة مكافحة حشرات بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/3azelhazna]شركة عزل خزانات بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/azelasth]شركة عزل اسطح بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/cleaningkazanat]شركة تنظيف خزانات بالرياض[/url]
[url=https://sites.google.com/site/servicescleaninig/cleaningglass]شركة تنظيف واجهات زجاج بالرياض[/url]
[/CODE]
If you put the request block in to a function, you can do requests all day.[/QUOTE]
0.1.9 — BETA 5.16