上传和后端脚本错误消息
如果 uploadify.php 后端脚本出现错误,是否可以修改队列项的消息?请参阅下面的模型。
即使后端脚本中存在验证错误,第一个(灰色)图像也将显示已完成。这有点误导。如果可能的话,我希望它看起来像上面的第二张图。我已经设法接近一些东西,但我认为这可能不是最好的解决方案,这就是我到目前为止所拥有的:
...
'onComplete' : function( event, ID, fileObj, response, data ) {
if ( 1 != response ) {
$( '#image-upload' + ID ).addClass( 'uploadifyError' );
$( '#image-upload' + ID + ' .percentage' ).text( ' - Upload Error' );
}
}
...
感谢您提前提供的所有帮助!
Is there anyway to modify the queue item's message if there is an error in the back end script of uploadify.php? See mock-up below.
The first (gray) image will display completed even if there is a validation error in the back end script. This is a bit misleading. I would like it to look like second image above if possible. I've managed to get something close but I'm thinking it might not be the best solution, this is what I have so far:
...
'onComplete' : function( event, ID, fileObj, response, data ) {
if ( 1 != response ) {
$( '#image-upload' + ID ).addClass( 'uploadifyError' );
$( '#image-upload' + ID + ' .percentage' ).text( ' - Upload Error' );
}
}
...
Thanks for any and all help in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关键是通过 onComplete 事件返回 FALSE,这允许我重写 .percentage DIV 的内容。
如果一切正常,我的后端脚本将返回 1,这允许 onComplete 触发它的默认函数。如果一切都不顺利,则返回特定类型错误的字符串。然后将其输入到 .percentage DIV 中。
The key was to returning FALSE with the onComplete event which allowed me to re-write the contents of the .percentage DIV.
My back end script will return 1 if everything is cool which allows onComplete to fire it's default function. If everything is not cool then a string is returned for the specific type of error. That then gets entered into the .percentage DIV.