$('#formId')。submit()无效

时间:2017-06-13 06:05:06

标签: jquery

我正在尝试 ContentValues values = new ContentValues(); DbHelper dbHelper = new DbHelper(context); SQLiteDatabase database; database= dbHelper.getWritableDatabase(); values.put(DbConstants.COLUMN_MEMBER, cartItemBean.getCOLUMN_MEMBER()); values.put(DbConstants.COLUMN_DATE, cartItemBean.getCOLUMN_DATE()); values.put(DbConstants.COLUMN_TIME, cartItemBean.getCOLUMN_TIME()); String sql2 = "UPDATE " + DbConstants.TABLE_CART + " SET " + DbConstants.COLUMN_MEMBER + " = '" + cartItemBean.getCOLUMN_MEMBER() + "' AND " + DbConstants.COLUMN_DATE + " = '" + cartItemBean.getCOLUMN_DATE() + "' AND " + DbConstants.COLUMN_TIME + " = '" + cartItemBean.getCOLUMN_TIME() + "' AND " + DbConstants.COLUMN_TOTAL_PRICE + " = '" + cartItemBean.getCOLUMN_TOTAL_PRICE() + "' AND " + "' WHERE " + DbConstants.COLUMN_PACKID + " = '" + cartItemBean.getCOLUMN_PACKID() + "' AND " + DbConstants.COLUMN_USERID + " = '" + cartItemBean.getCOLUMN_USERID() + "'"; database.execSQL(sql2); 使用upload的表单,但JQuery无效。

$('#formId').submit()

1 个答案:

答案 0 :(得分:3)

您的问题来自点击处理中的e.preventDefault();,您已经告诉过您要阻止提交发生。如果将该行相应地移动到if语句

 $(document).ready(function() {
    $('#submit').click(function(e) {
      var doc = $('#doc').val();
      var extension = doc.substring(doc.lastIndexOf(".") + 1, doc.length);
      extension = extension.toLowerCase();
      if (doc == '') {
        $('.status').html('Please select pricing document');
        e.preventDefault();
      } else if (extension != 'pdf') {
        $('.status').html('Document must be a pdf');
        e.preventDefault();
      } else {
        $('#docForm').submit();
      }
    });
  });

您的$('#docForm').submit()将被执行。但由于这已经是一个提交句柄else以及$('#docForm').submit();可以省略,因为它并不重要。