我有一个工作的ajax表单,但无论我尝试什么,它只会在textarea超过500个字符时才提交。我已经消除了它是一个maxlength问题。我觉得很奇怪的是,提交的html字符串/发布数据在提交时每行解析一个字符(仅失败超过500个字符)只有TEXTAREA并返回一个" 406 Not Acceptable"回复中的状态。
这是表单/ ajax submit:
submitHandler: function(form) {
$(form).ajaxSubmit({
type:"POST",
data: $(form).serialize(),
url:"insert.php",
success: function() {
$('#submitEvents :input').attr('disabled', 'disabled');
$('#submitEvents').fadeTo( "slow", 0.15, function() {
$(this).find(':input').attr('disabled', 'disabled');
$(this).find('label').css('cursor','default');
$('#success').fadeIn();
});
},
error: function() {
$('#contact').fadeTo( "slow", 0.15, function() {
$('#error').fadeIn();
});
}
});
}
然后是insert.php(" $ fluffy"是测试textarea用于消除可能限制文本的ajax规则。它是一个全新的textarea提交,没有限制,仍然失败但只有超过500个字符):
<?php
include 'db.php';
// Collect data from POST
$eventName = mysqli_real_escape_string($connection, $_POST['eventName']);
$registrationLink = mysqli_real_escape_string($connection, $_POST['registrationLink']);
$eventDate = mysqli_real_escape_string($connection, $_POST['eventDate']);
$expires = mysqli_real_escape_string($connection, $_POST['expires']);
$eventType = mysqli_real_escape_string($connection, $_POST['eventType']);
$eventLink = mysqli_real_escape_string($connection, $_POST['eventLink']);
$eventCity = mysqli_real_escape_string($connection, $_POST['eventCity']);
$eventZip = mysqli_real_escape_string($connection, $_POST['eventZip']);
$eventPrice = mysqli_real_escape_string($connection, $_POST['eventPrice']);
$eventDescription = mysqli_real_escape_string($connection, $_POST['eventDescription']);
$submitterName = mysqli_real_escape_string($connection, $_POST['submitterName']);
$submitterEmail = mysqli_real_escape_string($connection, $_POST['submitterEmail']);
$submitterPhone = mysqli_real_escape_string($connection, $_POST['submitterPhone']);
$fluffy = mysqli_real_escape_string($connection, $_POST['fluffy']);
// Insert data into DB
mysqli_query($connection,"INSERT INTO events (event_name, event_date, event_link, event_type, distance, event_city, event_state, event_zip, event_excerpt, event_description, event_price, registrar, register_link, created_on, expires, approved, submitter_name, submitter_email, submitter_phone, fluffy) VALUES ('$eventName','$eventDate','$eventLink','$eventType','$_POST[eventDistance]','$eventCity','$_POST[eventState]','$eventZip','$eventDescription','$eventDescription','$eventPrice','$_POST[registrar]','$registrationLink', now(), '$expires', '0', '$submitterName', '$submitterEmail', '$submitterPhone', '$fluffy')");
mysqli_close($connection)
&GT;
帖子数据如下所示:
0 e
1 v
10 F
100 r
1000 +
1001 p
1002 o
1003 r
1004 c
1005 h
1006 e
1007 t
1008 t
1009 a
101 a
1010 %
1011 2
1012 C
1013 +
1014 s
1015 h
1016 a
1017 n
1018 k
1019 +
102 t
1020 f
1021 a
1022 t
1023 b
1024 a
1025 c
1026 k
1027 +
1028 g
1029 r
103 i
1030 o
1031 u
1032 n
1033 d
1034 +
1035 r
1036 o
1037 u
1038 n
1039 d
104 o
1040 +
1041 b
1042 i
1043 l
1044 t
1045 o
1046 n
1047 g
1048 +
1049 h
105 n
1050 a
1051 m
1052 b
1053 u
1054 r
1055 g
1056 e
1057 r
1058 +
1059 c
106 l
1060 o
1061 r
1062 n
1063 e
1064 d
1065 +
1066 b
1067 e
1068 e
1069 f
107 i
1070 +
1071 f
1072 i
...持续2500行左右直到它显示有良好的数据:
eventCity Harrisburg
eventDate 2014-12-06
eventDescription ksfkj sfjlksjd flkjsflk jlksdfj lsdfjslkf djslkjf lksjf dlksjflks jflksjflk sjflkjsfk sjlkfj slkfjlskj fd
eventDistance 10 Kilometers
eventLink http://genericevent.com
eventName Fictitious Race
eventPrice 60
eventState AK
eventType 5K Walk/Run
eventZip 17102
expires 2014-12-05
fluffy Bacon ipsum dolor amet strip steak filet mignon pork belly leberkas bresaola boudin beef jerky tongue. Pastrami swine turducken fatback jerky. Turducken corned beef pork loin beef filet mignon boudin. Pig fatback salami rump, venison meatloaf ham hock pork loin leberkas shank prosciutto. Pork belly kevin bresaola tail, short ribs andouille cow filet mignon prosciutto. Drumstick beef ribs pastrami short ribs kielbasa. Pancetta beef ribs bresaola tri-tip, beef frankfurter doner ball tip meatball pork pastrami. Capicola brisket porchetta, shank fatback ground round biltong hamburger corned beef filet mignon. Shoulder pig shankle, short loin tail pork loin kevin chuck hamburger doner turducken chicken salami prosciutto venison. Venison t-bone chuck porchetta, ribeye chicken sausage kevin sirloin pig ham hock pastrami doner tongue leberkas. Venison pastrami t-bone andouille ribeye capicola sausage swine cow rump sirloin drumstick turducken bresaola. Turkey cupim spare ribs sirloin. Bresaola fatback prosciutto pork belly. Jerky ground round flank tri-tip cupim chuck sausage capicola boudin biltong fatback ham jowl alcatra leberkas. Beef ribs ham hock tail hamburger, strip steak turducken t-bone tongue rump pork loin jerky kevin biltong doner. Prosciutto filet mignon pork chop turducken brisket shank chuck sirloin jowl. Bacon pastrami andouille salami pork chop ground round tri-tip tongue bresaola tenderloin frankfurter kevin. Prosciutto corned beef ground round hamburger andouille.
感谢您为我提供的任何照片!