确定连接是否已断开

时间:2021-03-19 00:00:36

I connect to a .NET handler to upload an image using YAHOO.util.Connect.asyncRequest.

我连接到.NET处理程序以使用YAHOO.util.Connect.asyncRequest上传图像。

The handler then throws an exception because the file is too big. When the exception is thrown, the request connection is immediately cut meaning that the javascript callback for asyncRequest is not called and the user is not notified that the image upload failed.

然后处理程序抛出异常,因为文件太大。抛出异常时,会立即切断请求连接,这意味着不会调用asyncRequest的javascript回调,并且不会通知用户图像上载失败。

Is there any way to detect that the connection has been broken?

有没有办法检测到连接已被破坏?

1 个解决方案

#1


Are you supplying a 'failure' field in the callback object you're giving the YUI object? See http://developer.yahoo.com/yui/connection/#async

您是否在提供YUI对象的回调对象中提供“失败”字段?请参阅http://developer.yahoo.com/yui/connection/#async

I'm surprised the failure procedure is not being called in your error case. I'd file a bug with YUI. Also use Fiddler so you can watch and see exactly what is happening on the TCP stream.

我很惊讶你的错误案例中没有调用失败程序。我向YUI提交了一个错误。还可以使用Fiddler,这样您就可以观察并确切了解TCP流上发生的情况。

As an alternative to asyncRequest that would a) Provide a better user experience (and especially if your users are uploading large files) b) May well handle your error situation better, check out the YUI uploaded widget.

作为asyncRequest的替代方案,a)提供更好的用户体验(特别是如果您的用户正在上传大文件)b)可以更好地处理您的错误情况,查看YUI上传的小部件。

Once you get it working, it does a very nice job. See http://developer.yahoo.com/yui/uploader/

一旦你开始工作,它就会做得非常好。见http://developer.yahoo.com/yui/uploader/

#1


Are you supplying a 'failure' field in the callback object you're giving the YUI object? See http://developer.yahoo.com/yui/connection/#async

您是否在提供YUI对象的回调对象中提供“失败”字段?请参阅http://developer.yahoo.com/yui/connection/#async

I'm surprised the failure procedure is not being called in your error case. I'd file a bug with YUI. Also use Fiddler so you can watch and see exactly what is happening on the TCP stream.

我很惊讶你的错误案例中没有调用失败程序。我向YUI提交了一个错误。还可以使用Fiddler,这样您就可以观察并确切了解TCP流上发生的情况。

As an alternative to asyncRequest that would a) Provide a better user experience (and especially if your users are uploading large files) b) May well handle your error situation better, check out the YUI uploaded widget.

作为asyncRequest的替代方案,a)提供更好的用户体验(特别是如果您的用户正在上传大文件)b)可以更好地处理您的错误情况,查看YUI上传的小部件。

Once you get it working, it does a very nice job. See http://developer.yahoo.com/yui/uploader/

一旦你开始工作,它就会做得非常好。见http://developer.yahoo.com/yui/uploader/