jquery指定时间调用ajax,JQuery Ajax调用根据时间提交更多次

我读到了类似的问题,但我无法找到它为什么在这里执行它。 基本上jquery ajax调用发送一些信息提交。问题在于表单首次提交一次,然后第二次提交两次,第三次提交4次。我不明白问题在哪里。能否请你帮忙?JQuery Ajax调用根据时间提交更多次

$('#form10').submit(function() {

//Get the data from all the fields

var UserID = $('input[name=UserID]');

var problemID = $('input[name=problemID]');

var solution_text = $('textarea[name=solution_text]');

var MM_insert = $('input[name=MM_insert]');

//organize the data properly

var data = 'UserID=' + UserID.val() + '&problemID=' + problemID.val() + '&solution_text=' + solution_text.val() + '&MM_insert=' + MM_insert.val();

//show the loading sign

$('.loading').show().delay(1200).fadeOut();

//start the ajax

$.ajax({

//this is the php file that processes the data

url: "/js/ajax/add-comment.php",

//POST method is used

type: "POST",

//pass the data

data: data,

//Do not cache the page

cache: false,

//success

success: function (html) {

//if process.php returned 1/true (success)

if (html == 1) {

//hide the gif

$('.loading').fadeOut('slow');

//show the success message

$('#comment-success').delay(1000).slideDown('slow').delay(2000).slideUp('slow');

$('#comments').load('/js/ajax/comments2.php?problemID=' + problemID.val());

//if process.php returned 0/false (failed)

} else {

$('#error-msg2').show('slow');

}

}

});

//cancel the submit button default behaviours

return false;

});

PHP回代码

.............

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "comments")) {

$insertSQL = sprintf("INSERT INTO solution (UserID, solution_date, problemID, solution_text) VALUES (%s, %s, %s, %s)",

GetSQLValueString($UserID, "int"),

GetSQLValueString(date('Y-m-d H:i:s', mktime()), "text"),

GetSQLValueString($problemID, "int"),

GetSQLValueString($solution_text, "text"));

mysql_select_db($database_tccconn, $tccconn);

$Result1 = mysql_query($insertSQL, $tccconn) or die(mysql_error());

if($Result1) { echo '1';}

else

{ echo '0';}

}

形式

form method="post" action="" name="form10" id="form10">

代码FRM comments2

mysql_select_db($database_tccconn, $tccconn);

$query_rstcomments = sprintf("SELECT solution.solutionID, solution.UserID, solution.solution_date, solution.solution_text, solution.problemID, user.org_name FROM solution NATURAL JOIN user WHERE solution.problemID = %s ORDER BY solution.solutionID ASC", $colname_rstcomments);

$rstcomments = mysql_query($query_rstcomments, $tccconn) or die(mysql_error());

$row_rstcomments = mysql_fetch_assoc($rstcomments);

$totalRows_rstcomments = mysql_num_rows($rstcomments);

if($rstcomments) {

do { ?>

Posted by<?php echo ucwords(stripslashes($row_rstcomments['org_name'])); ?>
On <?php echo date("j F Y",strtotime($row_rstcomments['solution_date'])); ?>
at <?php echo date("H:i",strtotime($row_rstcomments['solution_date'])); ?>

} ?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值