drupal ajax 分页,drupal call ajax function
$delete_commant = l(t('X'), $url, array('attributes' =>
array('onclick' => 'return call_ajax(123)')));
when i put alert in call_ajax function definition, it is alerted, so i proceed to write the ajax post method, but when i click the link page getting refresh,
How to implement ajax in drupal
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);
}