我是初学者,我面临的问题是代码在chrome中工作正常但在mozilla firefox中没有工作。它没有在mozilla中正确运行脚本。当我们点击chorme中的continue按钮时工作正常且何时点击mozilla中的“继续”按钮然后同一页重新加载。请帮助我。
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="scripts/signup.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script src="scripts/hideShowPassword.min.js"></script>
</head>
<body >
<div style="clear:left;"> </div>
<div id="message">
</div>
<div id="erorr" class="pop-up" >
<div class="popBox" >
<div class="popScroll" >
<h2 id="h2error">Error Message</h2>
<h2 style="text-align:center;">Please fill all the field for Joining.</h2>
</div>
<a href="#link" class="close"><span>Back to links</span></a>
</div>
<a class="lightbox">Back to links</a>
</div>
<div id="confirm" class="pop-up" >
<div class="popBox" >
<div class="popScroll" >
<h2 id="h2confirm">Confirmation Message </h2>
<h2 style="text-align:center;">Confirmation Link is Send to Your Email.</h2>
</div>
<a href="" class="close"><span>Back to links</span></a>
</div>
<a class="lightbox">Back to links</a>
</div>
<div id="fbJoin" class="tabbedForm hidden facebookForm">
<div id="facebookPane" style="text-align: center"></div>
</div>
<div id="standardJoin" class="tabbedForm">
<form method="post" id="sform" >
<table border="0" cellpadding="3" cellspacing="0" class="striped">
<tr>
<td>Email address</td>
<td colspan="3"><input id="email" name="email" type="email" size="30" maxlength="255"
value=""/><span id="emailup"></span></td>
</tr>
<tr>
<td>First name</td>
<td><input id="fname" name="fName" type="text" size="15" maxlength="127"
value=""/> <span id="firstname"></span>
</td>
<td>Last name</td>
<td><input name="lname" id="lname" type="text" size="15" maxlength="127"
value=""/> <span id="lastname"> </span>
</td>
</tr>
<tr>
<td>Street Address</td>
<td><input name="Street" type="text" size="15" maxlength="127"
value=""/></td>
<td>Apt. or Suite</td>
<td><input name="Street2" type="text" size="15" maxlength="127"
value=""/></td>
</tr>
<tr >
<td>City</td>
<td><input name="City" type="text" size="15" maxlength="127"
value=""/></td>
<td>State / Prov</td>
<td>
<input id="state" type="text" value="" name="State"/>
<span id='prov'></span>
</td>
</tr>
<tr>
<td>Postal Code</td>
<td><input id="zip" name="Zip" type="text" size="16"
maxlength="16"
value=""/>
<span id='pcode'></span></td>
<td>Country</td>
<td>
<select id="addressCountry" name="Country">
<option value="">-- Select --</option>
<option value="United States" >United States</option>
<option value="Canada" >Canada</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="Australia" >Australia</option>
</select>
</td>
</tr>
<tr>
<td>Date of birth</td>
<td colspan="3">
<input type="hidden" name="dateOfBirthAttempt" value=""/>
<select name="month">
<option value="">MM</option>
<option value="01" >Jan</option>
<option value="12" >Dec</option>
</select> <select name="day">
<option value="">DD</option>
<option value="01" >1</option>
<option value="31" >31</option>
</select> <select name="year">
<option value="">YYYY</option>
<option value="1996" >1996</option>
<option value="1891" >1891</option>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td colspan="3"><label>
<input type="radio" name="gender"
value="Male" />
Male </label>
<label>
<input type="radio" name="gender"
value="Female" />
Female</label></td>
</tr>
<tr>
<td>Ethnicity</td>
<td colspan="3">
<select name="ethnicity" id="ethnicity">
<option value="">-- Select --</option>
<option value="Caucasian/White">
Caucasian/White
</option>
<option value="African American/Black">
African American/Black
</option>
<option value="Hispanic">Hispanic</option>
<option value="Asian">Asian</option>
<option value="Pacific Islander">
Pacific Islander
</option>
<option value="Native American">
Native American
</option>
<option value="other">Other</option>
</select>
</td>
</tr>
<tr>
<td>Choose a Password</td>
<td><input id="password1" name="password" type="password" size="15" maxlength="32"
value=""/> <span id='pwd1'></span>
</td>
<td>Re-enter Password</td>
<td><input name="password2" id="password2" type="password" size="15" maxlength="32"
value=""/><span id='pwd2'></span>
</td>
</tr>
</table>
<div id="submitButton" class="submit"><button class="button button-green" id="logup" >Continue</button></div>
</form>
</div>
</div>
</br>
</br>
<script>
$('#password1').hidePassword(true);
$('#password2').hidePassword('focus', {
toggle: { className: 'my-toggle' }
});
</script>
</body>
</html>
脚本页面
if($.cookie('useremail'))
{
window.location="panel.html";
}
$("#logup").click(function(e) {
$('span').slideUp('fast');
$.post('signup.php', $('#sform').serialize() +'&action='+ $(event.target).attr('id'), function(data) {
var i=0;
while(i!=data.lenght+1)
{
var id=data[i];
switch(id) {
case 0:
{
$('#emailup').html('The email entered is invalid.');
$('#email').focus();
$('#emailup').slideDown('fast');
break;
}
case 1:
{
$('#firstname').html('First Name start From letter.');
$('#fname').focus();
$('#firstname').slideDown('fast');
break;
}
case 2:
{
$('#lastname').html('Last Name start from letter.');
$('#lname').focus();
$('#lastname').slideDown('fast');
break;
}
case 3:
{
$('#prov').html('State/Prov start from letter.');
$('#state').focus();
$('#prov').slideDown('fast');
break;
}
case 4:
{
$('#pcode').html('Postal code is always in Numbers.');
$('#zip').focus();
$('#pcode').slideDown('fast');
break;
}
case 5:
$('#pwd1').html('Password range within 5-30.');
$('#password1').focus();
$('#pwd1').slideDown('fast');
break;
case 6:
{
$('#pwd2').html('Password Not match try again.');
$('#password2').focus();
$('#pwd2').slideDown('fast');
break;
}
case 7:
{
$('#emailup').html('This email already exist.');
$('#email').focus();
$('#emailup').slideDown('fast');
break;
}
case 8:
$('#emailup').html('error8.');
$('#email').focus();
$('#emailup').slideDown('fast');
$('#message').addClass(code);
$('#message').html('An error occurred, please try again.');
$('#message').slideDown('fast');
break;
case 9:
window.location="index.html#erorr";
break;
case 10:
window.location="index.html#confirm";
break;
default:
$('#message').addClass(code);
$('#message').html('An error occurred, please try again.');
$('#message').slideDown('fast');
}
i++;
}
},"json");
return e.preventDefault();
});
});
php code
require_once 'config.php';
//$array();
if(isset($_POST['email']) && isset($_POST['fName'])&& isset($_POST['lname']) && isset($_POST['Street']) && isset($_POST['Street2']) && isset($_POST['City']) && isset($_POST['State'])
&& isset($_POST['Zip'])&& isset($_POST['Country']) && isset($_POST['month']) && isset($_POST['day']) && isset($_POST['year']) && isset($_POST['gender']) && isset($_POST['ethnicity']) && isset($_POST['password']) && isset($_POST['password2']))
{
$email=$_POST['email'];
$fname=$_POST['fName'];
$lname=$_POST['lname'];
$street=$_POST['Street'];$suite=$_POST['Street2'];$city=$_POST['City'];$state=$_POST['State'];
$zip=$_POST['Zip'];$country=$_POST['Country'];
$month=$_POST['month'];$day=$_POST['day'];$year=$_POST['year'];
$gender=$_POST['gender'];$ethnicity=$_POST['ethnicity'];
$pwd=$_POST['password'];
$pwd2=$_POST['password2'];
$dob=$day."-".$month."-".$year;
$time=date('Y-m-d G:i:s');
extract($_POST);
$check=0;
if( !preg_match("^[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$^", $_POST['email']) )
{
$array[]=0;
$check=1;
//die ("<error id='0' />");
}
$data=mysql_query("select uemail from users where uemail='$email'") or die ("Erorr in selection of country");
$row=mysql_num_rows($data);
if($row!=0)
{
$array[]=7;
$check=1;
//die("<error id='7' />");
}
if(is_numeric($fname))
{
$array[]=1;
$check=1;
//die ("<error id='1' />");
}
if(is_numeric($lname))
{
$array[]=2;
$check=1;
//die ("<error id='2' />");
}
if(!is_numeric($zip))
{
$array[]=4;
$check=1;
//die ("<error id='4' />");
}
if(is_numeric($state))
{
$array[]=3;
$check=1;
//die ("<error id='3' />");
}
if( strlen($pwd)<5 )
{
$array[]=5;
$check=1;
//die("<error id='5' />");
}
if($pwd!=$pwd2)
{
$array[]=6;
$check=1;
//die ("<error id='6' />");
}
if($check==0)
{
$data=mysql_query("select cid from country where cname='$country'") or die ("Erorr in selection of country");
$datarow=mysql_fetch_array($data);
$cid=$datarow['cid'];
setcookie('cid',$cid,time()+3600*1,"/home/a3628191/public_html/","example.com",1,1);
$result=mysql_query("insert into users values ('NULL','$email','$fname','$lname','$street','$suite','$city','$state','$zip','$cid','$dob','$gender','$ethnicity','$pwd','0','$time')");
if(!$result)
{
$array[]=8;
}
else
{
setcookie('confirmation',$email,time()+3600*24);
$to = $email;
$link1="http://www.ohome.site40.net/confirm.php?";
$link2=$to;
$link=$link1.str_shuffle("abcdefghijklmnopqrstuvwxyz1234567890@#$/");
$subject = 'Confirm Your Subscription';
$headers = 'From: Surveys Bux <www.surveysBux.com>'. "\r\n";
$headers .= "Reply-To: ". strip_tags("inam.rao92@gmail.com") . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message.= '<div marginwidth="0" marginheight="0" style="background:#f5f5f5">';
$message.= '<center>';
$message.= '<table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">';
$message.= '<tbody><tr>';
$message.= '<td align="center" valign="top">';
$message.= '<table border="0" cellpadding="0" cellspacing="0" style="border:1px solid #ccc;width:600px;background:#ffffff">';
$message.= '<tbody><tr>';
$message.= '<td align="center" valign="top">';
$message.= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
$message.= '<tbody><tr>';
$message.= '<td valign="top" style="padding-top:10px;padding-right:20px;padding-bottom:10px;padding-left:20px;color:gray;font-family:Helvetica;font-size:10px;line-height:125%;text-align:left">';
$message.= ' Surveys available right now, complete your membership and start earning.';
$message.= '</td>';
$message.= '<td valign="top" style="padding-top:10px;padding-right:20px;padding-bottom:10px;padding-left:0;color:gray;font-family:Helvetica;font-size:10px;line-height:125%;text-align:left">';
$message.= ' Welcome! You are receiving this email because you expressed interest in joining Surveys Bux.';
$message.= ' </td>';
$message.= '</tr>';
$message.= '</tbody></table>';
$message.= '</td>';
$message.= '</tr>';
$message.= '<tr>';
$message.= '<td align="center" valign="top">';
$message.= '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
$message.= ' <tbody><tr>';
$message.= '<td valign="top" style="color:#505050;font-family:Helvetica;font-size:14px;line-height:150%;padding-top:20px;padding-right:20px;padding-bottom:20px;padding-left:20px;text-align:left">';
$message.= '<h1 style="color:#202020!important;display:block;font-family:Helvetica;font-size:26px;font-style:normal;font-weight:bold;line-height:100%;letter-spacing:normal;margin-top:0;margin-right:0;margin-bottom:10px;margin-left:0;text-align:left">Welcome to Surveys Bux!</h1>
Dear '; $message.= $fname; $message.=',<br>';
$message.= ' <br>';
$message.= 'Thank you for joining Surveys Bux!
To get started, <span style="background-color:#fcffaf;padding:2px">please click on the confirmation link below</span>.';
$message.= '<br><br>';
$message.= 'Once you have confirmed your membership, we will send you important
information on how to begin taking surveys and earning money.<br><br><br>';
$message.= '<table border="0" cellpadding="15" cellspacing="0">
<tbody><tr>
<td valign="middle" bgcolor="#2dc512">
<form action="';$message.= $link;$message.='" method="post">
<input type="hidden" name="verify" value="';$message.= $to;$message.='"/>
<button type="submit" style="color:white;width:180px height:150px;color:#fff;font-family:Arial;font-size:15px;font-weight:bold;letter-spacing:-.5px;line-height:100%;text-align:center;text-decoration:none;text-decoration:underline" target="_blank">Confirm and start earning</button>
</form>
</td>
</tr>
</tbody></table>
<br>
<br>';
$message.= 'Please also take a minute to record your sign in information:<br>
<br>
<strong>Username</strong>: <a style="color:black;text-decoration:none">'; $message.= $fname." ". $lname; $message.=' </a><br>
<strong>Password</strong>: (Not displayed for security reasons)<br>
<br>
You can update this information anytime by visiting the "<a href="#" target="_blank">My Profile</a>" section of our website. <br>
<br>
<br>
Go ahead! Join the finest minds in research!
<br>
<br>
Sincerely,<br>
<br>
<br>
Surveys Bux
<br>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td valign="top" style="padding-top:0;color:gray;font-family:Helvetica;font-size:10px;line-height:150%;padding-top:20px;padding-right:20px;padding-bottom:20px;padding-left:20px;text-align:left">
</td>
</tr>
<tr>
<td valign="top" style="padding-top:0;padding-bottom:40px;color:gray;font-family:Helvetica;font-size:10px;line-height:150%;color:gray;font-family:Helvetica;font-size:10px;line-height:150%;padding-right:20px;padding-bottom:20px;padding-left:20px;text-align:left">
This email was sent to <a style="color:black;text-decoration:none">{'; $message.=$to; $message.='} </a> because you expressed interest in joining Surveys Bux.
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<br>
<br>
</center><div class="yj6qo"></div><div class="adL">
</div></div>
</body>
</html>';
mail($to, $subject, $message, $headers);
$array[]=10;
//die ("<error id='8' />");
}
}
}
else
{
$array[]=9;
//die("<error id='9' />");
}
echo json_encode($array);
?>
答案 0 :(得分:1)
在您的JavaScript集e.preventDefault();
中,如下所示:
$("#logup").click(function(e) { e.preventDefault; .... // rest of your code
然后用return e.preventDefault();
转换return false;
。