【问题标题】:Can Dojo .ajax load image?Dojo .ajax 可以加载图像吗?
【发布时间】:2012-12-07 00:57:52
【问题描述】:

这里有一个关于 Jquery 的类似问题: Asynchronously load images with jQuery

接受的answer 非常聪明并且效果很好(对于Jquery):

var img = $("<img />").attr('src', 'http://somedomain.com/image.jpg')
  .load(function() {
      if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
          alert('broken image!');
      } else {
          $("#something").append(img);
      }
  });

我的问题是,在 Dojo 中与此等效的规范是什么(包括错误处理)?

【问题讨论】:

    标签: ajax image dojo


    【解决方案1】:

    您可以使用“dojox.form.Uploader”来ajax上传图片。

    道场代码:-

    require(['dojox/form/Uploader'],function(Uploader)
    {
        var uploader = new Uploader(
        {
           uploadOnSelect:true,   //Upload file on file select
           url:'UploadFile.php',  //Path of your server file
           label:'',              //Label of uploader
           multiple:true          //Select multiple file to upload
        },'uploader');
        uploader.startup();
    });
    

    HTML 代码:-

    <div id="uploader"></div>
    

    “dojox.form.Uploader”提供了各种帮助上传文件的属性、方法和事件。 我希望这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-09
      • 2013-09-15
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多