因缺乏支持而被删除

时间:2015-12-28 22:31:34

标签: javascript php jquery html forms

由于Stack Overflow社区缺乏友好和有用的响应,OP已删除了问题。

2 个答案:

答案 0 :(得分:4)

您可以使用以下代码禁用 Ctrl

$("#submit-btn-id").click(function (e) {
  // If there's a ctrl key pressed while clicking, please stop the event.
  if (e.ctrlKey)
    return false;
});

或者更好的方法是使用AJAX。您可以在form的提交事件中绑定AJAX函数:

$("form").submit(function (e) {
  e.preventDefault();
  $.post("action.php", $(this).serialize(), function (data) {
    alert(data);
  });
});

答案 1 :(得分:0)

只需从表单标记中删除操作

即可
$_SERVER['PHP_SELF'];

你可以这样做

<form action="" enctype="multipart/form-data" method="post" class="class" id="id" autocomplete="off">
    <input type="text">
    <input type="submit" value="SUBMIT">
</form>

或者你可以这样做

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post" class="class" id="id" autocomplete="off">
    <input type="text">
    <input type="submit" value="SUBMIT">
</form>

<强> AJAX

$(document).ready(function() {
    $('#form_id').submit(function() {
         $.ajax({
             url: 'your_page.php // and if it this page just put it's name.php',
             data: {field1: value1, field2: value2},
             type: 'post',
             dataType: 'json',
             beforeSend: function() {
                 // do something like show the loading,,,
             },
             success: function() {
                 // do something after the request has status of 200,,,
             },
             error: function() {
                 // do something if the request has error like 400, 500 server internal error/ page not found etc,,,
             },
             complete: function() {
                 // do something finish,,,
             },
         });
         return false;
    });
});