Php 在Internet Explorer上使用jquery的问题
Jquery在Internet explorer上不工作。但是,它在其他WebBrowser上运行。 我写的代码是Php 在Internet Explorer上使用jquery的问题,php,jquery,ajax,Php,Jquery,Ajax,Jquery在Internet explorer上不工作。但是,它在其他WebBrowser上运行。 我写的代码是 <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://ajax.micro
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#myform").validate({
debug: false,
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.",
},
submitHandler: function(form)
{
$.post('process.php', $("#myform").serialize(), function(data)
{
$('#results').html(data);
});
}
});
});
</script>
</head>
<body>
<form name="myform" id="myform" action="" method="POST">
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value=""/>
<br>
<label for="email" id="email_label">Email</label>
<input type="text" name="email" id="email" size="30" value=""/>
<br>
<input type="submit" name="submit" value="Submit">
</form>
<div id="results"><div>
</body>
</html>
$(文档).ready(函数(){
$(“#myform”)。验证({
调试:错误,
规则:{
名称:“必需”,
电邮:{
要求:正确,
电子邮件:真的
}
},
信息:{
姓名:“请让我们知道你是谁。”,
电子邮件:“有效的电子邮件将帮助我们与您取得联系。”,
},
submitHandler:函数(表单)
{
$.post('process.php',$(“#myform”).serialize(),函数(数据)
{
$('#results').html(数据);
});
}
});
});
名称
电子邮件
process.php
<?php
print "Form submitted successfully: <br>Your name is <b>".$_POST['name']."</b> and your email is <b>".$_POST['email']."</b><br>";
?>
如何在INTERNET EXPLORER上运行此代码。非常感谢您在这方面提供的任何帮助您应该将
return false
添加到submitHandler
或者,您可以使用submit
将提交输入转换为不提交表单的按钮,尝试以下代码:-
<script type="text/javascript">
$(document).ready(function(){
$("#myform").validate({
debug: false,
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.",
},
submitHandler: function(form)
{
$.post('process.php', $("#myform").serialize(), function(data)
{
$('#results').html(data);
});
return false;
}
});
});
</script>
$(文档).ready(函数(){
$(“#myform”)。验证({
调试:错误,
规则:{
名称:“必需”,
电邮:{
要求:正确,
电子邮件:真的
}
},
信息:{
姓名:“请让我们知道你是谁。”,
电子邮件:“有效的电子邮件将帮助我们与您取得联系。”,
},
submitHandler:函数(表单)
{
$.post('process.php',$(“#myform”).serialize(),函数(数据)
{
$('#results').html(数据);
});
返回false;
}
});
});
我试着在我这边执行你的代码。请在顶部添加doctype。我用了同样的,它在不起作用的时候就起作用了
<!DOCTYPE html>
谢谢删除这行后面的“,”
email: "A valid email will help us get in touch with you.",
应该是
email: "A valid email will help us get in touch with you."
在您的消息块中是这样的
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.", // <<<< HERE REMOVE IT
},
消息:{
姓名:“请让我们知道你是谁。”,
电子邮件:“一封有效的电子邮件将帮助我们与您取得联系。”,//您从JavaScript控制台收到错误消息了吗?您使用的是什么版本的IE?我们是开发人员,而不是魔术师:)没有错误。当我单击“提交”按钮时,我再次看到相同的页面,询问名称和电子邮件我添加了return false,但这没有什么区别:(尝试使用按钮标签
始终使用html5 doctype,而不要使用xhtml doctype!您正在使用哪个版本的Internet Explorer?我的朋友?它仍然不适用于我:(我正在使用iE8。您在页面顶部到底使用了什么。顺便说一句,请评论您的代码并尝试逐步调试它。否:(即使单击“提交”按钮,我仍然会看到相同的页面