AJAX beginner


Halaman [1], 2, 3, 4, 5  Berikutnya »
Kirim topik baru   Balas ke topik   Printer-friendly version    students.stttelkom.ac.id Forum -> Programming
Ke bawah?   Topik sebelumnya | Topik berikutnya  
hendito

user avatar
Offline
 Judul: AJAX beginner PostPosted: 19th Desember 2005, 18:38

alhamdulillah dah mulai belajar AJAX euy .. keren abis .... like gmail.com tuh ... builder class gratis dari SAJAX ( simple AJAX ) team .... integrasi with PHP ... keren ...

share yuk script-script sederhana dulu .... AJAX ( asynchronous Javascript and XML )

yummy

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
riojaya

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 19th Desember 2005, 19:02

ada yg mo blajar bareng? ikut....
----------------------------»
explode() or die();
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 19th Desember 2005, 19:11

Sajax is a cross-platform, cross-browser web scripting toolkit
that makes it easy to expose functions in your code to JavaScript. It's free

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
rifky_st3

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 27th Desember 2005, 23:00

AJAX bisa bikin gaya pemrograman web master bisa berubah nih. By the way dasarnya kita belajar XMLhttprequest.
----------------------------»
Kehidupan itu hanya sebentar..... Jangan terpesona kepadanya
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
riojaya

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 08:20

ada contoh script/source? upload dong...
----------------------------»
explode() or die();
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
tomfreakz

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 08:32

wah.. ajax... ikutan gw cuy... (blankie neeh)
kasih dong bang hendito yang kmarin kamu mulai plajari....

----------------------------»
choose ur life...
http://tomfreakz.blogspot.com


Di edit terakhir oleh tomfreakz pada 28th Desember 2005, 08:33 | Total edit: 1
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 08:33

rifky_st3 Tulis:
AJAX bisa bikin gaya pemrograman web master bisa berubah nih. By the way dasarnya kita belajar XMLhttprequest.


betul ... transfer database via javascript ... banyak kok yang dah pake .. contoh paling nyata tuh si gmail.com ... kemudian CMS berbayar seperti vBulletin ma Invision Power dah built in ....

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 08:38

ini file sajax.asp ... jadi AJAX on ASP programming

Kode:
<%

function r(str)
{
Response.write("<br>-"+str+"-<br>")
}

function Sajax(debug_mode)
{
this.debug_mode = debug_mode||false;
this.export_list = [];
this.js_has_been_shown = false;

this.handle_client_request = function()
{
func_name = Request.QueryString("rs");
if(!func_name||String(func_name)=="undefined") return false

//bust cache
Response.AddHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT")
//always modified
Response.AddHeader("Last-Modified", new Date().toGMTString().replace(/UTC/,"GMT"))
//HTTP/1.1
Response.AddHeader("Cache-Control", "no-cache, must-revalidate")
//HTTP/1.0
Response.AddHeader("Pragma", "no-cache")



if(this.export_list[func_name]=="undefined")
{
result = "-"+func_name+" is not callable";
//if(this.debug_mode) Response.write("-"+func_name+" is not callable");
}
else
{
rsargs_raw = Request.QueryString("rsargs[]")

rsargs = []
for(rs_i=1;rs_i<=rsargs_raw.Count;rs_i++)
{
rsargs[rs_i-1]=rsargs_raw(rs_i)
}

// if(this.debug_mode) Response.write("calling " + func_name + "(" +
// rsargs.join(",")+")")

eval_str = this.export_list[func_name]+"("+rsargs+")"

try
{
result = "+"+eval(eval_str);
}
catch(e)
{
result = "-"+e.message+" (x_"+eval_str+")";
}
}

Response.write(result+"[sajax_result________end]]")
//exit()
}

this.show_common_js = function()
{
js_debug_mode = this.debug_mode
js_string_out = " // remote scripting library\n" +
" // (c) copyright 2005 modernmethod, inc\n" +
" var rs_debug_mode = "+js_debug_mode+";\n" +
" var rs_obj = false;\n" +
" var rs_callback = false;\n" +
" \n" +
" function rs_debug(text) {\n" +
" if (rs_debug_mode)\n" +
" alert('RSD: ' + text)\n" +
" }\n" +
" \n" +
" function rs_init_object() {\n" +
" rs_debug('rs_init_object() called..')\n" +
" \n" +
" var A;\n" +
" try {\n" +
" A=new ActiveXObject('Msxml2.XMLHTTP');\n" +
" } catch (e) {\n" +
" try {\n" +
" A=new ActiveXObject('Microsoft.XMLHTTP');\n" +
" } catch (oc) {\n" +
" A=null;\n" +
" }\n" +
" }\n" +
" if(!A && typeof XMLHttpRequest != 'undefined')\n" +
" A = new XMLHttpRequest();\n" +
" if (!A)\n" +
" rs_debug('Could not create connection object.');\n" +
" return A;\n" +
" }\n"

Response.write(js_string_out)
}

this.rs_esc=function(val)
{

}

this.export_function = function()
{
for(var i=0;i<arguments.length;i++)
{
this.export_list[arguments[i]] = arguments[i];
}
}

this.show_javascript = function()
{
if(!this.js_has_been_shown)
{
this.show_common_js()
this.js_has_been_shown = true
}

for(func_name in this.export_list)
{
this.show_one(func_name);
}
}

this.rs_esc = function(val)
{
var dqex = /\"/g //"
return val.replace(dqex, '\\\\"')
}

this.show_one=function(func_name)
{
var svr, srl, qsr;

svr = Request.ServerVariables("SERVER_NAME")
srl = Request.ServerVariables("URL")
qsr = Request.ServerVariables("QUERY_STRING");
uri = svr + srl + qsr;

if(!(uri.indexOf('?')>-1))
{
uri += "?rs=" + escape(func_name)
}
else
{
uri += "&rs=" + escape(func_name)
}

escapeduri = this.rs_esc(uri)
js_string_out = " // wrapper for "+func_name+"\n" +
" function x_"+func_name+"(){\n" +
" // count args; build URL\n" +
" var i, x, n;\n" +
" //var url = 'http://"+escapeduri+"', a = x_"+func_name+".arguments;\n" +
" url = 'http://"+escapeduri+"', a = x_"+func_name+".arguments;\n" +
" for (i = 0; i < a.length-1; i++)\n" +
" url = url + '&rsargs[]=' + escape(a[i]);\n" +
" x = rs_init_object();\n" +
" x.open('GET', url, true);\n" +
" x.onreadystatechange = function() {\n" +
" if (x.readyState != 4)\n" +
" return;\n" +
" rs_debug('received ' + x.responseText);\n" +
" \n" +
" var status;\n" +
" var data;\n" +
" status = x.responseText.charAt(0);\n" +
" data = x.responseText;\n" +
" var pos = data.indexOf('[sajax_result________end]]');\n " +
" if (status == '-'){\n" +
" if("+this.debug_mode+"){alert('Error: ' + data.substring(1,pos));}}\n" +
" else \n" +
" a[a.length-1](data.substring(1,pos));\n" +
" }\n" +
" x.send(null);\n" +
" rs_debug('x_"+func_name+" url = ' + url);\n" +
" rs_debug('x_"+func_name+" waiting..');\n" +
" }\n"

Response.write(js_string_out)
}
}
%>

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 08:40

cara menggunakan sajax.asp .... di include-kan seperti berikut dan save code berikut dengan nama multiply.asp

Kode:
<%@ Language=JScript %>
<!--#include file="sajax.asp"-->

<%

function multiply(x, y) {
return x * y;
}

function add(x, y, z) {
return x + y + z;
}

sajax = new Sajax();
// sajax.debug_mode = true;
sajax.export_function("multiply","add");
sajax.handle_client_request();

%>
<html>
<head>
<title>Multiplier</title>
<script>
<%
sajax.show_javascript();
%>

function do_multiply_cb(z) {
document.getElementById("z").value = z;
}

function do_multiply() {
// get the folder name
var x, y;

x = document.getElementById("x").value;
y = document.getElementById("y").value;
x_multiply(x, y, do_multiply_cb);
}

function do_add_cb(z) {
document.getElementById("zza").value = z;
}

function do_add() {
// get the folder name
var x, y, z;

x = "'"+document.getElementById("xa").value+"'";
y = "'"+document.getElementById("ya").value+"'";
z = "'"+document.getElementById("za").value+"'";
x_add(x, y, z, do_add_cb);
}

</script>
</head>
<body>
<input type="text" name="x" id="x" value="2" size="3">
*
<input type="text" name="y" id="y" value="3" size="3">
=
<input type="text" name="z" id="z" value="" size="3">
<input type="button" name="check" value="Calculate"
onclick="do_multiply(); return false;">
<br>
try adding some strings, eg:
<input type="text" name="xa" id="xa" value="ex " size="3">
+
<input type="text" name="ya" id="ya" value="nihil, " size="3">
+
<input type="text" name="za" id="za" value="nihil fit" size="3">
=
<input type="text" name="zza" id="zza" value="" size="15">
<input type="button" name="check" value="Calculate"
onclick="do_add(); return false;">
</body>
</html>

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
riojaya

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 13:03

selain asp (maksudnya php) ada ga?
----------------------------»
explode() or die();
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 15:25

pemuda_workshop Tulis:
selain asp (maksudnya php) ada ga?


tentu saja ada kok ... seperti berikut ... dan save dengan nama sajax.php

Kode:
<?php
if (!isset($SAJAX_INCLUDED)) {

/*
* GLOBALS AND DEFAULTS
*
*/
$sajax_debug_mode = 0;
$sajax_export_list = array();
$sajax_request_type = "GET";
$sajax_remote_uri = "";

/*
* CODE
*
*/
function sajax_init() {
}

function sajax_get_my_uri() {
global $REQUEST_URI;

return $REQUEST_URI;
}

$sajax_remote_uri = sajax_get_my_uri();

function sajax_handle_client_request() {
global $sajax_export_list;

$mode = "";

if (! empty($_GET["rs"]))
$mode = "get";

if (!empty($_POST["rs"]))
$mode = "post";

if (empty($mode))
return;

if ($mode == "get") {
// Bust cache in the head
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
$func_name = $_GET["rs"];
if (! empty($_GET["rsargs"]))
$args = $_GET["rsargs"];
else
$args = array();
}
else {
$func_name = $_POST["rs"];
if (! empty($_POST["rsargs"]))
$args = $_POST["rsargs"];
else
$args = array();
}

if (! in_array($func_name, $sajax_export_list))
echo "-:$func_name not callable";
else {
echo "+:";
$result = call_user_func_array($func_name, $args);
echo $result;
}
exit;
}

function sajax_get_common_js() {
global $sajax_debug_mode;
global $sajax_request_type;
global $sajax_remote_uri;

$t = strtoupper($sajax_request_type);
if ($t != "GET" && $t != "POST")
return "// Invalid type: $t.. \n\n";

ob_start();
?>

// remote scripting library
// (c) copyright 2005 modernmethod, inc
var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>;
var sajax_request_type = "<?php echo $t; ?>";

function sajax_debug(text) {
if (sajax_debug_mode)
alert("RSD: " + text)
}
function sajax_init_object() {
sajax_debug("sajax_init_object() called..")

var A;
try {
A=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
A=new ActiveXObject("Microsoft.XMLHTTP");
} catch (oc) {
A=null;
}
}
if(!A && typeof XMLHttpRequest != "undefined")
A = new XMLHttpRequest();
if (!A)
sajax_debug("Could not create connection object.");
return A;
}
function sajax_do_call(func_name, args) {
var i, x, n;
var uri;
var post_data;

uri = "<?php echo $sajax_remote_uri; ?>";
if (sajax_request_type == "GET") {
if (uri.indexOf("?") == -1)
uri = uri + "?rs=" + escape(func_name);
else
uri = uri + "&rs=" + escape(func_name);
for (i = 0; i < args.length-1; i++)
uri = uri + "&rsargs[]=" + escape(args[i]);
uri = uri + "&rsrnd=" + new Date().getTime();
post_data = null;
} else {
post_data = "rs=" + escape(func_name);
for (i = 0; i < args.length-1; i++)
post_data = post_data + "&rsargs[]=" + escape(args[i]);
}

x = sajax_init_object();
x.open(sajax_request_type, uri, true);
if (sajax_request_type == "POST") {
x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
x.onreadystatechange = function() {
if (x.readyState != 4)
return;
sajax_debug("received " + x.responseText);

var status;
var data;
status = x.responseText.charAt(0);
data = x.responseText.substring(2);
if (status == "-")
alert("Error: " + data);
else
args[args.length-1](data);
}
x.send(post_data);
sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
sajax_debug(func_name + " waiting..");
delete x;
}

<?php
$html = ob_get_contents();
ob_end_clean();
return $html;
}

function sajax_show_common_js() {
echo sajax_get_common_js();
}

// javascript escape a value
function sajax_esc($val)
{
return str_replace('"', '\\\\"', $val);
}

function sajax_get_one_stub($func_name) {
ob_start();
?>

// wrapper for <?php echo $func_name; ?>

function x_<?php echo $func_name; ?>() {
sajax_do_call("<?php echo $func_name; ?>",
x_<?php echo $func_name; ?>.arguments);
}

<?php
$html = ob_get_contents();
ob_end_clean();
return $html;
}

function sajax_show_one_stub($func_name) {
echo sajax_get_one_stub($func_name);
}

function sajax_export() {
global $sajax_export_list;

$n = func_num_args();
for ($i = 0; $i < $n; $i++) {
$sajax_export_list[] = func_get_arg($i);
}
}

$sajax_js_has_been_shown = 0;
function sajax_get_javascript()
{
global $sajax_js_has_been_shown;
global $sajax_export_list;

$html = "";
if (! $sajax_js_has_been_shown) {
$html .= sajax_get_common_js();
$sajax_js_has_been_shown = 1;
}
foreach ($sajax_export_list as $func) {
$html .= sajax_get_one_stub($func);
}
return $html;
}

function sajax_show_javascript()
{
echo sajax_get_javascript();
}


$SAJAX_INCLUDED = 1;
}
?>

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 15:26

jika sajax.php di require-kan ke php jadi seperti berikut dan.. save sebagai multiply.php

Kode:
<?
require("Sajax.php");

function multiply($x, $y) {
return $x * $y;
}

sajax_init();
// $sajax_debug_mode = 1;
sajax_export("multiply");
sajax_handle_client_request();

?>
<html>
<head>
<title>Multiplier</title>
<script>
<?
sajax_show_javascript();
?>

function do_multiply_cb(z) {
document.getElementById("z").value = z;
}

function do_multiply() {
// get the folder name
var x, y;

x = document.getElementById("x").value;
y = document.getElementById("y").value;
x_multiply(x, y, do_multiply_cb);
}
</script>

</head>
<body>
<input type="text" name="x" id="x" value="2" size="3">
*
<input type="text" name="y" id="y" value="3" size="3">
=
<input type="text" name="z" id="z" value="" size="3">
<input type="button" name="check" value="Calculate"
onclick="do_multiply(); return false;">
</body>
</html>

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
tomfreakz

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 28th Desember 2005, 16:35

wuss hasilnya apa tu..
kekeke belum nyoba gw... ga ada web serper

itu script ngapain mas?

----------------------------»
choose ur life...
http://tomfreakz.blogspot.com
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
malix


Offline
 Judul: re: AJAX beginner PostPosted: 29th Desember 2005, 09:56

contoh implementasi ajax ada disini http://rpl.stttelkom.ac.id/w0lfengine/admin.php
semua link pake ajax, terutama di searchnya. page ga perlu di refresh...
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
hendito

user avatar
Offline
 Judul: re: AJAX beginner PostPosted: 3rd Januari 2006, 01:56

malix Tulis:
contoh implementasi ajax ada disini http://rpl.stttelkom.ac.id/w0lfengine/admin.php
semua link pake ajax, terutama di searchnya. page ga perlu di refresh...


keren bro .. dini hari ini lage Coding AJAX Internet Messaging .. keren Euy ... semoga bisa menjadi service yang digunakan di STT untuk CHATTING ... ringan banget pokoke .. prototipenya masih di localhost computer-ku neh ... lagi trial dulu

----------------------------»
to beLOVEd is Nothing
to beLOVEd by someone is Something
to beLOVEd by someone you LOVE is Everything
Balas dengan quote
Naik?
Lihat user's profile Kirim pesan pribadi
  
Kirim topik baru   Balas ke topik   Printer-friendly version    students.stttelkom.ac.id Forum -> Programming Waktu adalah GMT + 7 Jam
Halaman [1], 2, 3, 4, 5  Berikutnya »
Halaman 1 of 5
Anda tidak dapat kirim topik baru
Anda tidak dapat balas ke topik
Anda tidak dapat edit kiriman anda
Anda tidak dapat hapus kiriman anda
Anda tidak dapat memilih poling
Anda tidak bisa attach files
Anda tidak bisa download files

RDF/XML
Modified from phpNet © 2005 by students Crew