uploadify动态更新配置参数方法uploadifySettings()报错“updateSettings is not a function”之解决办法
2010-07-28 23:06
771 查看
昨天在为朋友的百居易旅游网使用uploadify插件解决上传文件过程中,在尝试调用动态更新配置参数的方法uploadifySettings()时,总是抛出一个“updateSettings is not a function”错误。
解决过程如下:
使用uploadify动态修改参数的方法。
$("#uploadify").uploadifySettings('scriptData',{'name':newName,'age':newAge});
是总是抛出“updateSettings is not a function”的错误。
经过仔细研究源代码及翻阅资料,发现了问题所在,描述如下:
如果浏览按钮没有显示的时候,调用动态更新参数的方法uploadifySettings就会报此错误。
例子:
<div style="display:none;">
<input type="file" name="uploadify" id="uploadify" />
</div>
说明: 浏览按钮被包裹在一个隐藏(style="display:none;")的div中。这种时候调用uploadifySettings就会报错。
解决:
1. 先将浏览按钮显示出来<div style="display:block;">。貌似废话,因为你一定要使用这个按钮来操作上传文件,否则也不用写这个插件了。
2. 在参数配置中配置onselect事件:
$("#uploadify").uploadify ({
'uploader' : uploadify.swf',
'script' : 'upload/',
'scriptData' : {'name':name,'age': age},
'method' : 'Get',
'onSelect' : function (event, queueID, fileObj)
{
$("#uploadify").uploadifySettings('scriptData',{'name':getName(),'age':getAge()});
}
});
这样,浏览按钮先显示了,可以调用uploadifySettings方法了,然后在浏览窗口选择文件的时候触发动态更新参数的方法。
3. 解决问题。。本文出自 “小船” 博客,请务必保留此出处http://desertboat.blog.51cto.com/1936274/362236
解决过程如下:
使用uploadify动态修改参数的方法。
$("#uploadify").uploadifySettings('scriptData',{'name':newName,'age':newAge});
是总是抛出“updateSettings is not a function”的错误。
经过仔细研究源代码及翻阅资料,发现了问题所在,描述如下:
如果浏览按钮没有显示的时候,调用动态更新参数的方法uploadifySettings就会报此错误。
例子:
<div style="display:none;">
<input type="file" name="uploadify" id="uploadify" />
</div>
说明: 浏览按钮被包裹在一个隐藏(style="display:none;")的div中。这种时候调用uploadifySettings就会报错。
解决:
1. 先将浏览按钮显示出来<div style="display:block;">。貌似废话,因为你一定要使用这个按钮来操作上传文件,否则也不用写这个插件了。
2. 在参数配置中配置onselect事件:
$("#uploadify").uploadify ({
'uploader' : uploadify.swf',
'script' : 'upload/',
'scriptData' : {'name':name,'age': age},
'method' : 'Get',
'onSelect' : function (event, queueID, fileObj)
{
$("#uploadify").uploadifySettings('scriptData',{'name':getName(),'age':getAge()});
}
});
这样,浏览按钮先显示了,可以调用uploadifySettings方法了,然后在浏览窗口选择文件的时候触发动态更新参数的方法。
3. 解决问题。。本文出自 “小船” 博客,请务必保留此出处http://desertboat.blog.51cto.com/1936274/362236
相关文章推荐
- jquery uploadify动态更新配置参数方法uploadifySettings()
- jquery中Uncaught TypeError: $(...).ajaxUpload is not a function(…)错误解决方法
- ajaxFileUpload :jQuery.handleError is not a function的解决方法
- ajaxfileupload.js上传文件时jQuery.handleError is not a function的 解决办法
- PHP Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法:
- 使用vue时Module build failed: TypeError: this._init is not a function错误的解决方法
- 控制台出现 jQuery 1.9 .live() is not a function 解决方法
- 附5、MDT 2013 Update 1批量部署-更新版无法修改共享文件夹参数的解决办法
- Sea.js出现Uncaught TypeError: object is not a function的解决方法
- warning: the 'gets' function is dangerous and should not be used.的解决办法
- jquery uploadify动态传递参数实现方法
- js错误"submit is not a function"的解决方法
- RHEL6 64bit下更改YUM配置。yum this system is not registered with rhn的解决办法
- 使用toFixed()函数时,出现“toFixed() is not a function”的解决办法
- jquery报.live() is not a function的解决方法
- "The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods i"解决方法
- getHibernateTemplate().update()方法更新不了解决办法
- Struts2-动态方法调用-Could not find action or result-Method update for action user is not allowed
- django配置settings时遇到Could not import settings 'conf.local'的解决方法
- yum在线更新出现This system is not registered with RHN等错误解决方法