【发布时间】:2011-07-27 13:29:33
【问题描述】:
<script type="text/javascript" src="/scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#SendReply").click(function(){
$(".error").hide();
var hasError = false;
var pathname = window.location.pathname;
var random = Math.random();
var messageVal = $("#InquiryResponse").val();
if(messageVal == 'Type your response in this space ...') {
$("#InquiryResponse").after('<span class="error"><br><br><font color="red">You forgot to type your response to the inquiry. Please type it in the above space and submit again.</font><br></span>');
hasError = true;
}
if(hasError == false) {
$(this).hide();
if (jQuery.browser.msie != true) {
$.post( "",
{ Detail: messageVal},
function(data) {
//alert("For non IE");
$("#InqRespForm").slideUp("slow", function() {
$("#InqRespForm").before('<h1>Success</h1><p><font color="green">Your message has been sent.</font></p>');
});
});
}
if (jQuery.browser.msie == true) {
jQuery.ajaxSetup({async:false});
$.post( pathname , { Detail: messageVal},function(data)
{
$("#InqRespForm").width($("#InqRespForm").parent().width()).slideUp("slow");
$("#InqRespForm").before('<h1>Success</h1><p><font color="green">Your message has been sent.</font></p>');
});
jQuery.ajaxSetup({async:true});
}
}
return false;
});
});
</script>
<form action="" method="post" id="InqRespForm" name=InqRespForm>
Reply to the above Inquiry : <br/>
<textarea rows="7" name="Detail" id="InquiryResponse" cols="60" colspan=2>Type your response in this space ...</textarea>
<br/>
<input id="SendReply" name="Send" type="submit" value="Send Response" alt="Reply to Inquiry" />
</form>
在提交表单时,我会发送一封电子邮件。它适用于 FF、Chrome 等。但我已经秃头试图在 IE8 中进行这项工作。如果你能指出解决方案,我会给你买啤酒。
【问题讨论】:
-
为什么你让 IE 同步发布而不是其他浏览器?
-
没有理由 - 我发布的内容在我尝试了所有内容后经过两天的演变。没有什么能让它发挥作用。请注意 - 前端行为没有任何问题。表单确实向上滑动并显示消息已发送 - 只有在 IE8 中没有发送消息。我认为问题在于 IE 上的 $.post 。我可能是错的。几天前我开始使用 jQuery。
标签: jquery internet-explorer-8 .post