【发布时间】:2009-08-04 03:55:28
【问题描述】:
我使用prototype做我的AJAX开发,我使用的代码是这样的:
somefunction: function(){
var result = "";
myAjax = new Ajax.Request(postUrl, {
method: 'post',
postBody: postData,
contentType: 'application/x-www-form-urlencoded',
onComplete: function(transport){
if (200 == transport.status) {
result = transport.responseText;
}
}
});
return result;
}
我发现“结果”是一个空字符串。所以,我尝试了这个:
somefunction: function(){
var result = "";
myAjax = new Ajax.Request(postUrl, {
method: 'post',
postBody: postData,
contentType: 'application/x-www-form-urlencoded',
onComplete: function(transport){
if (200 == transport.status) {
result = transport.responseText;
return result;
}
}
});
}
但它也不起作用。如何获取 responseText 以供其他方法使用?
【问题讨论】:
标签: ajax prototypejs javascript