[Linux-programlama] Re: php ve javascript ve ben

---------

[Linux-programlama] Re: php ve javascript ve ben

From: Zafer BAHADIR <zbahadir_at_bursa-linux.org>
Date: Fri, 21 Nov 2008 14:03:55 +0200
Message-ID: <4926A3AB.3070801@bursa-linux.org>

Şöyle basit çalışan bir örnek vermek isterim kütüphane kullanmayan
konunun daha iyi anlaşılması için.

<html>
<head>
<script language="javascript" type="text/javascript">
//Browser Support Code
function ajaxFunction(){
    var ajaxRequest; // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }

    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
    var goruntule = document.getElementById('divim');
        goruntule.innerHTML = ajaxRequest.responseText;

        }
    }
    ajaxRequest.open("GET", "page.php", true);
    ajaxRequest.send(null);
}

</script>
</head>

<body>
<div id="divim"></div> <br />
<input type="button" value="Gönder" onclick="ajaxFunction();" />
</body>
</html>

Azer Koculu yazmış:
> Onur "binbir cesit" diye bahsettigim sey, sunucuya veri gondermek icin
> kullanilan yontem.diger cozumlerde xhr kullanildigi icin hem post hem
> get tipi request kullanabilirsin. eger get isine yariyorsa yazdigim
> kisa cozum de isine yarayabilir.
>
> iyi calismalar
>
> 2008/11/21 onuRRR <cversuscobol_at_gmail.com>:
>
>> Azer Bey çözümünüz için teşekkürler,
>> bende sunucuya istek göndermede bin çeşit yollardan biri olan "post" u
>> kullanıyorum ve html den php ye veri gönderirken bir sıkıntı çekmiyorum,
>> tek problemim combobox dan javascripte aldığım veriyi php içinde kullanamam.
>>
>> 2008/11/21 Elvin Şiriyev <elvin_at_siriyev.net>
>>
>>> js: http://hukuk.com.tr/js/SelectTree.v.2.0.js
>>>
>>>
>>>
>>> içerisinde birkaç ajax kütüphanesine göre (JQuery, Mootools, Prototype)
>>> yazılmış. etrafındaki /* ve */ leri kaldırısan kullanırsın.
>>>
>>>
>>> HTML:
>>> <dt><label for="city" class="optional">İşletme Adres (İl)</label></dt>
>>>
>>>
>>>
>>> <dd>
>>> <select name="city" id="city" SelectTreeGroup="group2" Level="0"
>>> URL="/ajax/getplaces" Label="Seçiniz" EmptyLabel="Null"
>>> style="width:250px;">
>>>
>>>
>>>
>>>
>>> </select></dd>
>>> <dt><label for="district_id" class="optional">İşletme Adres
>>> (İlçe)</label></dt>
>>>
>>>
>>>
>>> <dd>
>>> <select name="district_id" id="district_id" SelectTreeGroup="group2"
>>> Level="1" URL="/ajax/getplaces" Label="Seçiniz" EmptyLabel="Önce İl Seçiniz"
>>> style="width:250px;">
>>>
>>>
>>>
>>> </select></dd>
>>>
>>> /ajax/getplaces php kodu :
>>> if (isset($_GET['1'])) {
>>> $parts = new Parts();
>>> $res = $parts->fetchAll("ilce_id = {$_GET['1']}");
>>> } elseif (isset($_GET['0'])) {
>>> $districts = new Districts();
>>> $res = $districts->fetchAll("il_id = {$_GET['0']}");
>>> } else {
>>> $cities = new Cities();
>>> $res = $cities->fetchAll();
>>> }
>>> $rtrn = array();
>>> foreach ($res as $row) {
>>> $rtrn[] = array('value'=>$row->id, 'name'=>$row->name);
>>> }
>>> echo json_encode($rtrn);
>>>
>>> PS: örnek il ilçe seçimi içindir.
>>>
>>> --
>>> Elvin Şiriyev
>>> http://siriyev.net
>>>
>>> _______________________________________________
>>> Linux-programlama mailing list
>>> Linux-programlama_at_liste.linux.org.tr
>>> http://liste.linux.org.tr/mailman/listinfo/linux-programlama
>>>
>>>
>>
>> --
>> antiCobol..
>>
>> _______________________________________________
>> Linux-programlama mailing list
>> Linux-programlama_at_liste.linux.org.tr
>> http://liste.linux.org.tr/mailman/listinfo/linux-programlama
>>
>>
>>
>
>
>
>

_______________________________________________
Linux-programlama mailing list
Linux-programlama_at_liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama
Received on Fri 21 Nov 2008 - 13:12:14 EET

---------

Bu arsiv hypermail 2.2.0 tarafindan uretilmistir.