doujiao7520 2014-12-12 14:13
浏览 51

Ajax表单不会提交超过500个字符的textarea(406错误)

I have a working ajax form but no matter what I try it will not submit ONLY if the textarea is over 500 characters. I have eliminated it being a maxlength issue. What I find odd is that the html string/post data when submitted parses out one character per line on submit (which fails only over 500 characters) ONLY OF THE TEXTAREA and returns a "406 Not Acceptable" status in the response.

This is the form/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();
                });
            }
        });
    }

And then the insert.php ("$fluffy" is the test textarea being used to eliminate ajax rules that could possibly limit text. It's a brand new textarea being submitted with no limits and still fails but only if over 500 characters):

<?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)

?>

The post data looks like this:

    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

...which goes on for 2500 lines or so until it shows there is good data:

    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.

Thanks for anything you could illuminate for me!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂