**DEVELOPMENT.JS**
jQuery(function ($) {
$("#doContact").click(function(e) {
e.preventDefault();
alert("ho"); // ---- It doesn't alert ----
$("#contact-result").html('<img src="<%THEME%>images/loading.gif">');
var formData = $("#registerForm").serialize();
$.post("?page=register", formData, function(response)
{
if(response.status == 'success')
{
$.modal.close();
$('#register-success').modal({ opacity:80 });
}
else
{
$("#register-result").addClass('register-error');
$("#register-result").html(response.error_message);
}
},'json');
});
});
**CONTACTFORM.HTML**
<form id="contactForm" action="#" method="post" class="centered stylish">
<div id="contact-result">
<div>
<p><label for="username" class="label">Adınız:</label>
<input id="username" placeholder="Adınız..." name="username" maxlength="20" type="text" tabindex="1" class="input" /></p>
<p><label for="email" class="label">Email: (geri dönüş için gerekli)</label>
<input id="email" placeholder="Email adresiniz..." name="email" maxlength="70" type="text" tabindex="2" autocomplete="off" class="input"/></p>
<p><label for="message" class="label">Mesajınız:</label>
<textarea id="message" placeholder="Mesajınız..." cols="60" rows="10" name="message" maxlength="1000" type="text" tabindex="2" autocomplete="off" class="input"/></p>
<p>
<button id="doContact" class="ui-button button1" type="submit">
<span class="button-left">
<span class="button-right">Mesajımı Gönder</span>
</span>
</button>
</p>
</div>
</div>
</form>
问题很简单。
jQuery 目前适用于放置在页面加载中的其他 div。(例如导航栏右上角的黄色登录区域)
但是,这个表单是由 AJAX 调用加载的,所以我相信我需要使用类似delegate
or的函数live
。不过,我不知道是不是这样。
你能看看吗?