前もって謝らせてください、昨日のようにjqueryのことを始めたばかりなので、ゆっくり話して初心者用語をたくさん使ってください。とにかく、jquery/ajax 連絡先フォームの更新を停止して同じページに留まらせようとしていますが、「ReferenceError: $ is not defined」というエラーが表示され続けます。これを修正して、ここでの失敗に関連しているかどうかを調べようとしています。
ここにHTMLがあります......
<div id="contact">
<h2>Contact</h2>
<div class="clear"></div>
<div class="contactContainer">
<h3>Get in touch:</h3>
<div class="contact">
<form action="js/ajaxcontactform/sendmail.php" method="post" id="contactForm">
<ul>
<li>
<label for="name">Name:<font color="#ff3300">*</font></label>
<input type="text" name="name" value="" id="name" />
</li>
<li>
<label for="email">Email:<font color="#ff3300">*</font></label>
<input type="text" name="email" value="" id="email" />
</li>
<li>
<label for="tele">Telephone:</label>
<input type="text" name="tele" value="" id="tele" />
</li>
<li class="special" style="display: none;">
<label for="last">Don't fill this in:</label>
<input type="text" name="last" value="" id="last" />
</li>
<li>
<label for="message">Message:<font color="#ff3300">*</font></label><textarea rows="5" name="message"></textarea>
</li>
<li class="submitbutton">
<input type="submit" class="btn" value="Send Message" />
</li>
</ul>
</form>
ここにphpがあります.....
<?php
// basic settings section
$sendto = 'your@email.com';
$subject = 'You have a new message from your virtual resume!';
$iserrormessage = 'There was a problem with sending e-mail to us, please check:';
$thanks = "Thank's for your message! I'll contact you as soon as possible!";
$emptyname = 'Did you enter your name?';
$emptyemail = 'Did you enter your e-mail address?';
$emptymessage = 'Did you enter the message?';
$emptyphone = 'Did you enter phone number?';
$alertname = 'Please enter your name with standard alphabet!';
$alertemail = 'Please enter your e-maill address in format: name@domain.com';
$alertmessage = "Please do not use any parenthesis or other escaping characters. Standard web url's should work fine!";
$alertphone = 'Please enter your phone number without any special characters, only numbers ex: 5553212';
$alert = '';
$iserror = 0;
// cleaning the post variables
function clean_var($variable) {$variable = strip_tags(stripslashes(trim(rtrim($variable))));return $variable;}
// validation of filled form
if ( empty($_REQUEST['name']) ) {
$iserror = 1;
$alert .= "<li>" . $emptyname . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {
$iserror = 1;
$alert .= "<li>" . $alertname . "</li>";
}
if ( empty($_REQUEST['email']) ) {
$iserror = 1;
$alert .= "<li>" . $emptyemail . "</li>";
} elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {
$iserror = 1;
$alert .= "<li>" . $alertemail . "</li>";
}
if ( empty($_REQUEST['message']) ) {
$iserror = 1;
$alert .= "<li>" . $emptymessage . "</li>";
} elseif ( ereg( "[][{}*+\\^|]", $_REQUEST['message'] ) ) {
$iserror = 1;
$alert .= "<li>" . $alertmessage . "</li>";
}
// if there was error, print alert message
if ( $iserror==1 ) {
echo "<script type='text/javascript'>$(\".message\").hide(\"slow\").fadeIn(\"slow\").delay(5000).fadeOut(\"slow\"); </script>";
echo "<strong>" . $iserrormessage . "</strong>";
echo "<ul>";
echo $alert;
echo "</ul>";
} else {
// if everything went fine, send e-mail
$msg = "From: " . clean_var($_REQUEST['name']) . "\n";
$msg .= "Email: " . clean_var($_REQUEST['email']) . "\n";
$msg .= "Message: \n" . clean_var($_REQUEST['message']);
$header = 'From:'. clean_var($_REQUEST['email']);
mail($sendto, $subject, $msg, $header);
echo "<script type='text/javascript'>$(\".message\").fadeOut(\"slow\").fadeIn(\"slow\").animate({opacity: 1.0}, 5000).fadeOut(\"slow\");</script>";
echo $thanks;
die();
}
?>
標準のjquery.form.jsを使用しています(私が知る限り)
よろしくお願いします!