JSON often applied in the application of AJAX alternatively other usage XML. Solution about AJAX have ever been discussed in former edition of PC Media, but merely reminding again, marginally AJAX is engineering to create the application of web which interaktif, doesn't fail with the application of desktop. This thing makes difference line between the application of web and the application of desktop increasingly thin.
Web interaktif, it is of course entangles transfer of data between servers and browser, data format utilized better have the character of universal, light, and easy to be implementation.
Because that is XML often applied in the application of AJAX. But now, AJAX has JSON alternatively new couple. Although XML likely has bound AJAX through abbreviations AJAX itself: Asynchronous JavaScript and XML, but what is the meaning a name? This thing validitys only, Let's say AJAX nor will fail with selebriti in the case of change repeatedly couple.
But hitting its(the gum is isn't it programmer? Because having to studies again new programming, new way, new engineering, and so? If so, blames just of programmer ( what makes JSON and other technology), because creating all the things the has just.
A few messages of morale if as programmer we complain because studying new thing: work of programmer claimed to create new thing, its(the example from making the application of simple, makes manual system to become automatic, or even makes rival JSON ( might possibly, not?), where the masterpiece has just meaned if some'x to apply or studies it, then what is the reason of we to complain because there is new thing of which must be studied?
Even though, selective remain to be keyword to study technology.
Returns at couple JSON and AJAX, following will be presented combination trap simple sample JSON and AJAX. We will make the application of web presenting simple at random a song taken away from gathering of song with data format JSON.
Prepares a ? le text as data, name berry ? le following with datatxt, is containing:
{“ playing”:[
{“ title”: “ Bat Country”,
“ singer”: “ Avenged Sevenfold”
},
{“ title”: “ Amazing”,
“ singer”: “ Aerosmith”
},
{“ title”: “ Pull Me Under”,
“ singer”: “ Dream Theater”
}]
}
Example of data above menyimpan three fruit of song title along with name of penyanyi/band bringing it. The next of we will make a ? le HTML, berry name of with indexhtml, and contains code as follows:
< html>
< head>
< title> JSON - Ajax Demo < /title>
< script type=”text/javascript”>
var url = “ datatxt”;
function handleHttpResponse() {
if ( httpreadyState == 4)
if(httpstatus==200) {
var results = eval(‘(‘ + httpresponseText + ‘)');
// random from 0 to 2
var rand_no = Mathrandom();
rand_no = rand_no * 3;
rand_no = Mathceil(rand_no);
rand_no = rand_no - 1;
documentwrite(“ - by “);
}
}
}
function requestInput() {
httpopen(“GET”, url, true);
httponreadystatechange = handleHttpResponse;
httpsend(null);
}
function getHTTPObject() {
var xmlhttp;
if(windowXMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else if ( windowActiveXObject){
xmlhttp=new ActiveXObject(“MicrosoftXMLHTTP”);
if (! xmlhttp){
xmlhttp=new ActiveXObject(“Msxml2XMLHTTP”);
}
}
return xmlhttp;
}
var http = getHTTPObject();
< /script>
< /head>
< body>
< INPUT type=”button” id=button2 onclick=”requestInput()”
value=”Sekarang Is Turning Around Song...” />
< /body>
< /html>
Implements indexhtml at your browser through HTTP. Initial appearance would like at Gambar 1.
If You clicks nipple “ Now Medium MemutarLagu...”, hence will come up at random a song title along with its(the singer like at Gambar 2.
Purposive sample made to be basic and simple, because after you comprehends mode of action of above program, hence you will be able to do modi?kasi further don't know by using database, or applies programming language PHP, ASP/ASPNET, and so.

