大家好我有这个jquery,它调用一个页面将电子邮件插入新闻列表。
调用被触发两次,网址有一个奇怪的_参数,我没有添加两个网址,只需点击一下即可调用 :
http://www.camerich.co.uk/newsletter_add.php?emailtoadd=meeny@dizzyhigh.com&_=1310316941893
http://www.camerich.co.uk/newsletter_add.php?emailtoadd=meeny@dizzyhigh.com&_=1310316941906
如何通过重复???
来停止呼叫Jquerycode:
$('.searchbox_submit').click(function() { // start the click function for news_submit div
// get the email address that has been entered
var emailtoadd = $("#emailtoadd").val();
// set the url to load
var loadUrl = "newsletter_add.php?emailtoadd="+emailtoadd;
// set the status to let the user know we are loading in the data
$("#newsresponse").empty().html('<img src="/images/site/loadinfo.gif" width="16" height="16" align="absbottom" /> Processing Request...');
//load in the data
$.get(loadUrl, {}, function(myData) {
// add the response to the newsresponse div
$("#newsresponse").empty().html(myData);
}); // end get request
});//end click function
HTML code:
<div class="iconthumbs" style="background-image:url(images/icons/smaller/subscribe_button.jpg)">
<div id="searchwrapper" name="searchForm">
<div class="errortxt" id="newsresponse" style="padding:0 0 0 15px;"></div>
<input type="text" class="searchbox" name="emailtoadd" id="emailtoadd" style="color: #FFF" onClick="this.value='';" onFocus="this.select()" onBlur="this.value=!this.value?'Enter Email To Subscribe':this.value;" value="Enter Email To Subscribe" />
<input type="image" src="/images/site/1px.gif" class="searchbox_submit" id="news_submit" value="" />
</div>
</div>
答案 0 :(得分:1)
JQuery添加“_”以通过IE缓存。这包含自调用时间以来的时间。
对于你给出的例子,时间似乎是
1310317101270 = Sun, 10 Jul 2011 16:58:21 GMT
1310317079839 = Sun, 10 Jul 2011 16:57:59 GMT
相隔大约22秒。你确定他们来自同一个电话吗?
PS:使用this将纪元转换为时间
答案 1 :(得分:0)
为什么不使用jquery.one()
?
$('.searchbox_submit').one('click',function(){
//code
});
答案 2 :(得分:0)
尝试通过阻止输入图像按钮的默认提交操作来启动单击功能:
$('.searchbox_submit').click(function(e) {
e.preventDefault();
// rest of your code