Merhaba, Ziyaretçi. Lütfen giriş yapın veya üye olun.
Aktivasyon mailiniz gelmediyse buraya tıklayın.
05, 2008, 10:10:14 pm
42717 Mesaj 8081 Konu Gönderen: 17909 Üye
Son üye: bytasarimci
Turk-Php.Com Forum  |  Yardım Forumları  |  HTML & JavaScript & XML Forumu  |  AJAX  |  Basit Ajax Kütüphanesi « önceki sonraki »
Sayfa: [1] Yazdır
Yazan Konu: Basit Ajax Kütüphanesi  (Okunma Sayısı 705 defa)
OnurPhp
Yeni Kullanıcılar
*
Offline Offline

Mesaj Sayısı: 4


Üyelik Bilgileri
Basit Ajax Kütüphanesi
« : 14, 2007, 09:19:54 am »

Kod:
<script type="text/javascript">
/**
 * Ajax Asynchronous Javascript & XML
 *
 * Ajax Library
 *
 * Copyright (C) 2006 Onur Yerlikaya
 * LICENCE : This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * @category Core
 * @package Ajax
 * @author Onur Yerlikaya <onur.yerlikaya@linux.org.tr>
 * @version 0.0.1
 * @link http://www.onuryerlikaya.com
 * @licence GNU General Public Licence - Version 2
 * @copyright Onur Yerlikaya
 */

// XML Request Object
var http = cReq();

// XML Reques Result
var response = null;

/**
 * Create Request Object Function
 *
 * @return object
 */
function cReq() {
// XML Request Object
var xml;

if(window.XMLHttpRequest)
{
xml = new XMLHttpRequest();
} else if(window.ActiveXObject) {
try {
xml = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
try {
xml = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {}
}
} // end if
return xml;
}

/**
 * Send Request Function
 *
 * @param array params Parametres for request
 * @param string url Request URL
 * @param string method Request Send Method ( GET || POST )
 */
function sendReq(params,url,method) {
// Checks Request Method
if(method == "POST") {
// Open POST Request
http.open('POST',url,true);
// Send Request Header
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
} else {
// Open GET Request
http.open('GET',url,true);
}
// Call function when state change
http.onreadystatechange = handleResponse;
// Send parametres..
http.send(params);
}

/**
 * Handle Response
 */
function handleResponse() {
// Check state
if(http.readyState == 4) {
// Check Server Status
if(http.status == 200) {
// Assign Response
setRes(http.responseText);
} else {
// Give an alert for problem
alert('Problem - handleResponse !');
}
}
}

function setRes(getResponse)
{
response = getResponse;
}

function getRes()
{
return response;
}
</script>

Kullanım Şekli :

İştek Gönder :
Kod:
sendReq(null,'oku.pp','GET');

Sonuç Al :
Kod:
sonuc = getRes();
alert(sonuc);
« Son Düzenleme: 14, 2007, 09:21:57 am Gönderen: OnurPhp » Logged
mudkicker
Arif Ender
Admin
*
Offline Offline

Mesaj Sayısı: 873

Mastered PHP


Üyelik Bilgileri WWW
Ynt: Basit Ajax Kütüphanesi
« Yanıtla #1 : 15, 2007, 01:42:16 am »

Merhaba,

Sana bir tavsiye, mümkün olduğunca fonksiyonlarını, methodlarını kolay anlaşılabilir ve görevi adından belirlenebilir şekilde adlandır.
Uzun veya kısa olması aşırı önemli değil ama bu bir bakım kullanıcı-dostu bir kodlama olur.

Umarım daha da geliştirirsin. Eline sağlık.
Logged

sote
Yeni Kullanıcılar
*
Offline Offline

Mesaj Sayısı: 5


PHP 5


Üyelik Bilgileri
Ynt: Basit Ajax Kütüphanesi
« Yanıtla #2 : 10, 2007, 03:03:00 pm »

eburhan'a gönder bence. Cheesy eyceks'ten daha kolay bir kütüphane arıyordu. Smiley
Logged

Çalışmazsan, kazanamazsın...
Denesen denesen başaramazsın...
Sayfa: [1] Yazdır 
« önceki sonraki »
Gitmek istediğiniz yer:  


Turk-Php.Com Forum | SMF Forum Software © 2005, Simple Machines LLC. All Rights Reserved.