志愿者表单超出最大调用堆栈大小

时间:2016-12-09 06:58:53

标签: javascript php jquery forms post

我的表单在某一时刻工作得很好,然后我添加了一些额外的表单数据字段,并且繁荣开始得到这个。

Here是JS的链接,它正在抱怨

以下是我点击错误时控制台带给我的内容:

function Vc(a, b, c, d) {
        var e;
        if (m.isArray(b))
            m.each(b, function(b, e) {
                c || Rc.test(a) ? d(a, e) : Vc(a + "[" + ("object" == typeof e ? b : "") + "]", e, c, d)
            });
        else if (c || "object" !== m.type(b))
            d(a, b);
        else
            for (e in b)
                Vc(a + "[" + e + "]", b[e], c, d)
    }

与此同时

type: function(a) {
            return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h[i.call(a)] || "object" : typeof a
        }



Here是表单HTML代码的链接。

表格JS

$(function() {

    $("#contact_form input,#contact_form textarea").jqBootstrapValidation({
        preventSubmit: true,
        submitError: function($form, event, errors) {
            // something to have when submit produces an error ?
            // Not decided if I need it yet
        },
        submitSuccess: function($form, event) {
            event.preventDefault(); // prevent default submit behaviour
            // get values from FORM
            var name = $("input#name").val();
            var lastName = $("input#lastName").val();
            var gender = $("select#gender").val();
            var phone = $("input#phone").val();
            var email = $("input#email").val();
            var address = $("input#address").val();
            var city = $("input#city").val();
            var state = $("select#state").val();
            var country = $("select#country").val();
            var zip = $("input#zip").val();
            var title = $("select#title").val();
            var otherTitle = $("input#otherTitle").val();
            var specialty = $("select#specialty").val();
            var otherSpecialty = $("input#otherSpecialty").val();
            var skill = $("select#skill").val();
            var otherSkill = $("input#otherSkill").val();
            var africa = document.getElementById("africa").checked;
//            var africa = $("input#africa").checked;
            var caribbean = document.getElementById("caribbean").checked;
//            var caribbean = $("input#caribbean").checked;
            var eSeAsia = document.getElementById("eseAsia").checked;
//            var eSeAsia = $("input#eseAsia").val();
            var europe = document.getElementById("europe").checked;
//            var europe = $("input#europe").val();
            var india = document.getElementById("india").checked;
//            var india = $("input#india").val();
            var latinAmerica = document.getElementById("latinAmerica").checked;
//            var latinAmerica = $("input#latinAmerica").val();
//            var arabic = $("input#arabic").val();
            var arabic = document.getElementById("arabic").checked;
            var arabicLevel = $("select#arabicLevel").val();
//            var chinese = $("input#chinese").val();
            var chinese = document.getElementById("chinese").checked;
            var chineseLevel = $("select#chineseLevel").val();
//            var english = $("input#english").val();
            var english = document.getElementById("english").checked;
            var englishLevel = $("select#englishLevel").val();
//            var french = $("input#french").val();
            var french = document.getElementById("french").checked;
            var frenchLevel = $("select#frenchLevel").val();
//            var german = $("input#german").val();
            var german = document.getElementById("german").checked;
            var germanLevel = $("select#germanLevel").val();
//            var hindi = $("input#hindi").val();
            var hindi = document.getElementById("hindi").checked;
            var hindiLevel = $("select#hindiLevel").val();
//            var korean = $("input#korean").val();
            var korean = document.getElementById("korean").checked;
            var koreanLevel = $("select#koreanLevel").val();
//            var lao = $("input#lao").val();
            var lao = document.getElementById("lao").checked;
            var laoLevel = $("select#laoLevel").val();
//            var portuguese = $("input#portuguese").val();
            var portuguese = document.getElementById("portuguese").checked;
            var portugueseLevel = $("select#portugueseLevel").val();
//            var spanish = $("input#spanish").val();
            var spanish = document.getElementById("spanish").checked;
            var spanishLevel = $("select#spanishLevel").val();
//            var vietnamese = $("input#vietnamese").val();
            var vietnamese = document.getElementById("vietnamese").checked;
            var vietnameseLevel = $("select#vietnameseLevel").val();
//            var other = $("input#other").val();
            var other = document.getElementById("other").checked;
            var otherLevel = $("select#otherLevel").val();
            var otherInput = $("input#otherInput").val();
            var volunteerYes = document.getElementById("volunteerYes").checked;
            var organizationCountry = $("input#volunteerCountry").val();
            var volunteerNo = document.getElementById("volunteerNo").checked;
            var message = $("textarea#message").val();

            var firstName = name; // For Success/Failure Message
            // Check for white space in name for Success/Fail message
            if (firstName.indexOf(' ') >= 0) {
                firstName = name.split(' ').slice(0, -1).join(' ');
            }
            $.ajax({
                url: "./bin/volunteer.php",
                type: "POST",
                data: {
                    name: name,
                    lastName: lastName,
                    gender: gender,
                    phone: phone,
                    email: email,
                    address: address,
                    city: city,
                    state: state,
                    country: country,
                    zipcode: zip,
                    Title: title,
                    otherTitle: otherTitle,
                    specialty: specialty,
                    otherSpecialty: otherSpecialty,
                    skill: skill,
                    otherSkill: otherSkill,
                    africa: africa,
                    caribbean: caribbean,
                    eSeAsia: eSeAsia,
                    europe: europe,
                    india: india,
                    latinAmerica: latinAmerica,
                    arabic: arabic,
                    arabiclevel: arabicLevel,
                    chinese: chinese,
                    chineselevel: chineseLevel,
                    english: english,
                    englishlevel: englishLevel,
                    french: french,
                    frenchlevel: frenchLevel,
                    german: german,
                    germanlevel: germanLevel,
                    hindi: hindi,
                    hindilevel: hindiLevel,
                    korean: korean,
                    koreanlevel: koreanLevel,
                    lao: lao,
                    laolevel: laoLevel,
                    portuguese: portuguese,
                    portugueselevel: portugueseLevel,
                    spanish: spanish,
                    spanishlevel: spanishLevel,
                    vietnamese: vietnamese,
                    vietnameselevel: vietnameseLevel,
                    other: other,
                    otherlevel: otherLevel,
                    otherlanguage: otherInput,
                    volunteerYes: volunteerYes,
                    volunteerCountry: volunteerCountry,
                    volunteerNo: volunteerNo,
                    message: message
                },
                cache: false,
                success: function() {
                    // Success message
                    $('#success').html("<div class='alert alert-success'>");
                    $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
                        .append("</button>");
                    $('#success > .alert-success')
                        .append("<strong>Your message has been sent. </strong>");
                    $('#success > .alert-success')
                        .append('</div>');

                    //clear all fields
                    $('#contact_form').trigger("reset");
                },
                error: function() {
                    // Fail message
                    $('#success').html("<div class='alert alert-danger'>");
                    $('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
                        .append("</button>");
                    $('#success > .alert-danger').append("<strong>Sorry " + firstName + " it seems that my mail server is not responding...</strong> Could you please email me directly to <a href='mailto:me@example.com?Subject=Message_Me from myprogrammingblog.com;>me@example.com</a> ? Sorry for the inconvenience!");
                    $('#success > .alert-danger').append('</div>');
                    //clear all fields
                    $('#contact_form').trigger("reset");
                },
            })
        },
        filter: function() {
            return $(this).is(":visible");
        },
    });

    $("a[data-toggle=\"tab\"]").click(function(e) {
        e.preventDefault();
        $(this).tab("show");
    });
});


/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
    $('#success').html('');
});

php-form 在这里看起来像这样:

<?php
// Check for empty fields
if(empty($_POST['name'])      ||
   empty($_POST['lastName'])      ||
   empty($_POST['gender'])      ||
   empty($_POST['email'])     ||
   empty($_POST['phone'])     ||
   empty($_POST['address'])     ||
   empty($_POST['city'])     ||
   empty($_POST['state'])     ||
   empty($_POST['country'])     ||
   empty($_POST['zipcode'])     ||
   empty($_POST['message'])   ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
   echo "No arguments Provided!";
   return false;
   }



// Create the email and send the message
$to = 'youngmarines37@gmail.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.

$email_subject = "Website Volunteer Form:  $name";
    $email_body = "You have received a new message from
    your website volunteer form.\n\n".
    "Here are the details:\n";


    foreach($_POST as $key => $value) {
        $value = strip_tags(htmlspecialchars($value));
        if($value!="" && $value!="false") {
            $email_body .= "$key : $value \n";
        }
    }


/*
$email_subject = "Website Volunteer Form:  $name";
$email_body = "You have received a new message from
your website volunteer form.\n\n".
"Here are the details:\nFirst Name: $name\nLast Name: $lastName\nGender: $gender\n\nEmail: $email_address\nPhone: $phone\n\n
Address: $address\nCity: $city\nState: $state\nCountry: $country\nZip: $zipcode\n\n
Medical Degree/Title: $Title\nSpecality: $specialty\nNon-Medical Skill: $skill\n\n
Interested in Africa: $africa\nInterested in Caribbean: $caribbean\nInterested in E. or S.E. Asia: $eSeAsia\nInterested in Europe: $europe\nInterested in India: $india\nInterested in Latin America: $latinAmerica\n\n
Message:\n$message";
*/
$headers = "From: noreplyw4wh@gmail.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>

0 个答案:

没有答案