Prototype ajax get,post例子

get请求

function getExample()
{
var url=”demo.aspx”;
var params=”u=abc”;
var myAjax=new Ajax.Request(url,{method:’get’,parameters:params,onComplete:showResult});
}

function showResult(originalRequest)
{
alert(originalRequest.responseText);
}

post请求

function getExample()
{
var url=”demo.aspx”;
var params=”u=abc”;
var myAjax=new Ajax.Request(url,{method:’post’,postBody:params,onComplete:showResult});
}

function showResult(originalRequest)
{
alert(originalRequest.responseText);
}

你可能感兴趣的:(Prototype ajax get,post例子)