利用yui动态上传文件

xiaoxiao2026-08-18  3

使用yui上传文件,动态刷新页面和一般情况有些不同。这里主要有三点要注意:

第一是 $C.setForm(form, true); 这里要设置成true,表示要upload文件。

第二点是在设置上传成功后的处理方法时,要以“upload”为成功的状态:

$C.asyncRequest("POST", _url, { upload:function(o){...} });

 第三点是在firefox下通过json返回的responseText格式上有问题,firefox会添加<pre>...</pre>标签,导致responseText不能正常被解析。解决的办法如下:

var res; var json = o.responseText; if(json.indexOf('<pre>') != -1) { // firefox has this bug res = eval("(" + json.substring(5, json.length-6)+ ")"); } else { res = eval("(" + json + ")"); }  

 

转载请注明原文地址: https://www.6miu.com/read-5051434.html

最新回复(0)