如何取得同步时的返回值呢?

4 views
Skip to first unread message

bellone.wu

unread,
Jan 15, 2008, 8:08:24 AM1/15/08
to buffalo与Amowa
GlobalCommonsFalse.prototype.ValidStringReplyStr = function(obj) {
if(obj == null || obj.value == null || obj.value == "")return "";
return
this.globalBuffaloFalse.remoteCall("commonOrder.ValidStringReplyStr",
[obj.value], function(reply) {
var obj_value = reply.getResult();
if(obj_value != "-1"){
alert("您输入的字符有非法字符,请检查,谢谢!!!");
//obj.focus();
return "-1";
}else{
return "";
}
});
}

我在this.globalBuffaloFalse.remoteCall前加了return了,可是还是没有返回值呀,我
globalBuffaloFalse这个对像是同步方式,请问有没办法取到这个反回值呢??

宋来

unread,
Jan 15, 2008, 7:28:23 PM1/15/08
to am...@googlegroups.com
var a;
a = -1;
return a;

Michael Chen

unread,
Jan 15, 2008, 9:41:57 PM1/15/08
to am...@googlegroups.com
remoteCall没有返回值。可以类似于

var a;

buffalo.remoteCall(......function(reply) {
...
a = -1;
})

return a;

2008/1/16 宋来 <qson...@gmail.com>:


> var a;
> a = -1;
> return a;
>
>
> >
>

--
Michael Chen
--------------------------------
Blog: http://michael.nona.name
MSN: jzch...@hotmail.com

bellone.wu

unread,
Jan 16, 2008, 3:00:08 AM1/16/08
to buffalo与Amowa
可是这样子的返回值在跨js脚本文件调用,还真的不直观呀.如果能取到call的返回值那就太好了,因为业务麻烦的关系,最好能根据返回值下文再需要做
一些业务的判断.



On 1月16日, 上午10时41分, "Michael Chen" <mechil...@gmail.com> wrote:
> remoteCall没有返回值。可以类似于
>
> var a;
>
> buffalo.remoteCall(......function(reply) {
> ...
> a = -1;
>
> })
>
> return a;
>
> 2008/1/16 宋来 <qsong...@gmail.com>:
>
> > var a;
> > a = -1;
> > return a;
>
> --
> Michael Chen
> --------------------------------
> Blog:http://michael.nona.name
> MSN: jzche...@hotmail.com

Michael Chen

unread,
Jan 16, 2008, 6:08:49 AM1/16/08
to am...@googlegroups.com
如果这样的需求很多,可以包装一个方法:

function syncCall(service, parameter) {
var result = null;
buffalo.remoteCall(service, parameters, function(reply) {
result = reply.getResult();
})
return result;
}

以后只调用这个方法就够了

2008/1/16 bellone.wu <bello...@gmail.com>:

MSN: jzch...@hotmail.com

Reply all
Reply to author
Forward
0 new messages