只有在使用IE6时,jquery ajax表单插件才会多次提交到服务器
我都喜欢。 我使用以下表单在j2ee服务器上临时上传照片,然后使用imageAreaSelect插件裁剪照片:只有在使用IE6时,jquery ajax表单插件才会多次提交到服务器,jquery,ajax,forms,submit,internet-explorer-6,Jquery,Ajax,Forms,Submit,Internet Explorer 6,我都喜欢。 我使用以下表单在j2ee服务器上临时上传照片,然后使用imageAreaSelect插件裁剪照片: <form name="formAvatarName" id="formAvatar" method="post" action="../admin/admin-avatar-upload" enctype="multipart/form-data"> <label>Upload a Picture of Yourself</label> <
<form name="formAvatarName" id="formAvatar" method="post"
action="../admin/admin-avatar-upload"
enctype="multipart/form-data">
<label>Upload a Picture of Yourself</label>
<input type="file" name="upload" id="upload" size="20" />
<input type="button" id="formAvatarSubmit" value="formAvatar" onclick="invia()"/>
</form>
下面是用作提交事件处理程序的javascript函数:
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
log.debug('About to submit: \n\n' + queryString);
return true;
}
function showResponse(responseText, statusText, xhr, $form) {
myRes=responseText;
log.debug('status: ' + statusText + '\n\nresponseText: \n' + responseText);
//box uploaded
$('div#avatar-upl > img').replaceWith(myRes);
var origWidth = $('div#avatar-upl > img').width();
var origHeight = $('div#avatar-upl > img').height();
log.debug('AjaxUpload onComplete(): orig size w,h : ' + origWidth + ', ' + origHeight);
//scaling uploaded
$('div#avatar-upl > img').jScale(
{ls:'300px'},
function(){
var scaleWidth = $(this).width();
var scaleHeight = $(this).height();
log.debug('AjaxUpload onComplete(): scaled size w,h : ' + scaleWidth + ', ' + scaleHeight);
//put scaled sizes on img custom attribute, to be retrieved from preview() method
$('div#avatar-upl > img').attr('scaleWidth', scaleWidth);
$('div#avatar-upl > img').attr('scaleHeight', scaleHeight);
}
);
//box thumbnail
$('div#avatar-thumb > img').replaceWith(myRes);
$('div#avatar-thumb > img').css({
width: 100,
height: 100
});
//setup of imgAreaSelect
$('div#avatar-upl > img').imgAreaSelect({
handles: true,
onSelectEnd: avatarPreview
});
}
这是html:
<div id="avatar-mng">
<div id="avatar-upl">
<img id="img-upl" style="margin: 0 0.3em;" src="../res/img/spacer.gif" />
</div>
<div id="avatar-thumb" style="width: 100px; height: 100px; overflow: hidden; float:right;">
<img id="img-thumb" src="../res/img/spacer.gif" style="width: 100px; height: 100px;" />
</div>
<form name="formAvatarName" id="formAvatar" method="post" action="../admin/admin-avatar-upload" enctype="multipart/form-data">
<label>Upload a Picture of Yourself</label>
<input type="file" name="upload" id="upload" size="20" />
<input type="button" id="formAvatarSubmit" value="formAvatar" onclick="invia()"/>
</form>
</div>
上传一张你自己的照片
只有在使用IE6进行测试时,我才能看到对服务器的sumbission被执行了多次(第一次得到上传的文件时,其他时候sumbmission看起来是空的,我得到了错误)。有了IE7、IE8、FFOX,CHROME工作正常
有什么想法吗?
多谢各位 您很可能没有达到返回false的程度,因此IE继续以“自然”的方式以及通过
ajaxSubmit()
提交表单。您的选项
指定一个成功
回调。showResponse()
看起来像什么?可能showResponse()中的某些内容使IE出错,因此无法运行return false
。我会在没有成功回调的情况下尝试您的代码,然后从那里开始。您的“aho”警报会弹出两次吗?我的警报只会弹出一次。空提交的错误是什么?你怎么能看到当IE6出现时,会有多个提交?注:当IE6=PI在服务器端有struts时,应该显示警报(“更新浏览器”);通过在操作上使用断点,我可以看到多个提交。不幸的是,IE6是我们的应用程序必须遵守的浏览器标准。
<div id="avatar-mng">
<div id="avatar-upl">
<img id="img-upl" style="margin: 0 0.3em;" src="../res/img/spacer.gif" />
</div>
<div id="avatar-thumb" style="width: 100px; height: 100px; overflow: hidden; float:right;">
<img id="img-thumb" src="../res/img/spacer.gif" style="width: 100px; height: 100px;" />
</div>
<form name="formAvatarName" id="formAvatar" method="post" action="../admin/admin-avatar-upload" enctype="multipart/form-data">
<label>Upload a Picture of Yourself</label>
<input type="file" name="upload" id="upload" size="20" />
<input type="button" id="formAvatarSubmit" value="formAvatar" onclick="invia()"/>
</form>
</div>