我似乎已经准备好了一切,
<script language="javascript" type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="js/mailing-list.js"></script>
在标题中,mailing-list.js
在 js 文件夹中。然而由于某种原因,它似乎没有解析。我已经粘贴了下面的内联代码 - 有什么想法吗?
var emailEntered,
nameVal,
compVal,
foneVal,
cityVal,
$(document).ready(function () {
$("#SendButton").click(function () {
$(".error").hide();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal = $("#email").val();
if (emailaddressVal == '') {
$("#message").html('<span class="error">Enter your email address before submitting.</span>');
return false;
} else if (!emailReg.test(emailaddressVal)) {
$("#message").html("<span class='error'>That is not an email address. Typo?</span>");
return false;
} else {
emailEntered = escape($('#email').val());
}
nameVal = escape($("#name").val());
emailVal = escape($("#email").val());
compVal = escape($("#comp").val());
foneVal = escape($("#fone").val());
cityVal = escape($("#city").val());
});
$('#signup').submit(function () {
$("#message").html("<span class='error'>Adding your email address...</span>");
$.ajax({
url: 'inc/store-address.php',
data: 'ajax=true&email=' + emailEntered + '&name=' + nameVal + '&comp=' + compVal + '&fone=' + foneVal + '&city=' + cityVal,
success: function (msg) {
$('#message').html(msg);
}
});
return false;
});
});
更新:通过解析,我的意思是对 mailing-list.js 的调用被忽略了。