AJAX is based on XML output of XMLHTTPRequest class, but JAH is AJAX without XML, it is based on Text output of XMLHTTPRequest class.
 
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: JAH: Javascript Asynchronous HTML

Nice link Naren !
Really liked the idea !
Keep it up ! 1/25/2006 3:33 AM | ram

# re: JAH: Javascript Asynchronous HTML

JAH.js Content
======================================
function jah(url,target) {
// native XMLHttpRequest object
document.getElementById(target).innerHTML = 'sending...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send();
}
}
}

function jahDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="jah error:\n" +
req.statusText;
}
}
}

Explaination:-
======================================
<p>You just include &lt;script language="javascript1.3" src="jah.js" &gt;&lt;/script&gt; in the &lt;head&gt; and then link to dynamic pages with &lt;a href="javascript:jah('kevin.html','target');"&gt;kevin&lt;/a&gt; where target is the id of the HTML element you want to replace.</p>
======================================
4/18/2010 7:04 PM | Naren

# re: JAH: Javascript Asynchronous HTML

Thanks, this is a great piece of code. However, can you please provide another version of this jah code which use POST method rather than GET method? because GET method has limitation on the volumn of data to be passed to the server!
:-(

Sorry for asking, I am a newbie on this. 8/23/2010 2:52 AM | yh

# re: JAH: Javascript Asynchronous HTML

How to enable execute script on the html page which is called under a specific div

Tried :-
var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
var bMoz = (navigator.appName == 'Netscape');
function execJS(node) {
var st = node.getElementsByTagName('SCRIPT');
var strExec;
for(var i=0;i<st.length; i++) {
if (bSaf) {
strExec = st[i].innerHTML;
}
else if (bOpera) {
strExec = st[i].text;
}
else if (bMoz) {
strExec = st[i].textContent;
}
else {
strExec = st[i].text;
}
try {
eval(strExec.split("<!--").join("").split("-->").join(""));
} catch(e) {
alert(e);
}
}
}

But the script for e.g :-

<body>
<script language=javascript">
document.write("Test");
</script>
</body>

Please help me its almost 4 days i am working on it.

Thank You 8/26/2010 3:37 PM | Anwar

Post a comment





 

 

News

Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Archives

Post Categories

Image Galleries

Articles & Magazines

ASP.Net 2.0 Compilation

ASP.Net, Blogs I refer...

Atlas

Dost

Drivers and Software Download

Garhwal

Travel Domain

WSS and WebParts

Syndication: