被这个问题困扰了不少时间,把解决的函数记录下来留此存照.
<script src="prototype-1.6.0.3.js" type="text/javascript"></script>
<script src="json2.js" type="text/javascript"></script>
<script type="text/javascript">
function validateID() {
var url = "validateID";
var params = Form.Element.serialize("id");
var myAjax = new Ajax.Request(url, {
method : "post",
parameters : params,
onComplete : processResponse,
asynchronous : true
});
}
function processResponse(request) {
var action = JSON.parse(request.responseText);
$("tip").innerHTML = action.tip;
if (action.flag) {
document.all("submit").disabled = true;
} else {
document.all("submit").disabled = false;
}
}
function refresh() {
document.getElementById("authImg").src = "auth.jpg?now=" + new Date();
}
</script>