drupal qo'ng'iroq ajax funktsiyasi

$delete_commant = l(t('X'), $url, array('attributes' => array('onclick' => 'return call_ajax(123)')));

call_ajax funktsiyasi ta'rifiga ogohlantirish berganda, u ogohlantiriladi, shuning uchun ajax post uslubini yozishga kirishishni davom ettiraman, lekin bog'lanish sahifasini yangilashni boshlaganimda,

Drupal-da ajaxni qanday ishlatish kerak

function call_ajax(str){alert(str);
    var url = "post.php";
    var params = "lorem=ipsum&name=binny";
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    http.onreadystatechange = function() {//Call a function when the state changes.
        if(http.readyState == 4 && http.status == 200) {
            alert(http.responseText);
        }
    }
    http.send(params);  
     }
1
shuning uchun siz http deb atalmaysiz deb o'ylayman.
qo'shib qo'ydi muallif Human Love, manba
Ushbu misolni ishga tushirish bilan sinab ko'rdingizmi ular xmlhttp; w3schools.com/ajax/ ajax_aspphp.asp
qo'shib qo'ydi muallif Human Love, manba
firefox-da firebug bo'lsa, ogohlantirish o'rniga console.log harakat qilib ko'ring
qo'shib qo'ydi muallif Human Love, manba
atleast bu xatoni bilishi kerak, lekin X tugmasini bosganimda, uni faqatgina sahifani yangilab turish kerak
qo'shib qo'ydi muallif bharanikumar Bs, manba

2 javoblar

0
qo'shib qo'ydi
operatsiyani amalga oshiradigan bir misolni taqdim etsam, x tugmachasini bosganimda, orqa pog'onada jarayonni o'chirib tashlashni va tugatish tugallangandan keyin bir ogohlantirish xabari kerak.
qo'shib qo'ydi muallif bharanikumar Bs, manba

O'ylaymanki, siz onclick ishlovchilarida yolg'onchi ekansiz. Lekin jQuery haqida biroz ko'proq ma'lumot va Ko'zda tutilmagan JavaScript .

0
qo'shib qo'ydi