drbl91357 2017-04-15 09:09
浏览 94
已采纳

jQuery AJAX仅在18个args上达到内存堆栈限制

So I have a form that is submitted through jQuery AJAX and around 18 arguments are passed to a php file. Now whenever I try to submit the form, stack limit is reached with that many arguments. But the moment I cut off like half the arguments, the forms works fine and email is received. But the email I receive does not have any body.

AJAX:

$.ajax({
                    url: "sendemail.php",
                    method: "post",
                    data: {
                        name: name,
                        email: email,
                        number: number,
                        username: username,
                        country: country,
                        cname: cname,
                        ctype: ctype,
                        ctheme: ctheme,
                        domainname: domainname,
                        webhosting: webhosting,
                        seo: seo,
                        gadvertising: gadvertising,
                        cmarketing: cmarketing,
                        ptech: ptech,
                        details: details,
                        description: description
                    },
                    success: function () {
                        alert("Hey brotha");
                    }
                }).fail(function () {
                    $("#confdiv").html("<p class='alert alert-danger'>There was an error submitting your form. Please try again later or contact us at <a href='mailto:sobanr4@gmail.com'>EMAIL</a></p>");
                    window.scrollTo(0, 100);
                });

the php script is:

    <?php

if (isset($_POST['name']) && $_POST['name'] != "") {

    $to = "sobanr4@gmail.com";
    $subject = "Website Order Request";
    $headers = "From: <".$_POST['email'].">
";
    $headers .= "MIME-Version: 1.0" . "
";
    $headers .= "Content-type:text/html;charset=UTF-8" . "
";
    $body = "<html>
    <head>
        <title>Order Request - ".$_POST['name']."</title>
    </head>
    <body>
        <p>NAME: ".$_POST['name']."</p>
        <p>EMAIL: ".$_POST['email']."</p>
        <p>NUMBER: ".$_POST['number']."</p>
        <p>USERNAME: ".$_POST['username']."</p>
        <p>COUNTRY: ".$_POST['country']."</p>
        <p>COMPANY NAME: ".$_POST['cname']."</p>
        <p>TYPE: ".$_POST['ctype']."</p>
        <p>THEME: ".$_POST['ctheme']."</p>
        <p>DOMAIN NAME: ".$_POST['domainname']."</p>
        <p>WEB HOSTING: ".$_POST['webhosting']."</p>
        <p>SEO: ".$_POST['seo']."</p>
        <p>GOOGLE ADVERTISING: ".$_POST['gadvertising']."</p>
        <p>CONTENT MARKETING: ".$_POST['cmarketing']."</p>
        <p>PERMANENT TECHNICIAN: ".$_POST['ptech']."</p>
        <br><br><br>
        <p>DETAILS: ".$_POST['details']."</p>
        <br><br><br>
        <p>DESCRIPTION: ".$_POST['description']."</p>
    </body>
    </html>";

    if (mail($to,$subject,$$body,$headers)) {
        echo 1;
    } else {
        echo 0;
    };

}

?>

The form can be found here: http://www.henryspike.tk/testform

展开全部

  • 写回答

2条回答 默认 最新

  • doujiebo9849 2017-04-16 03:48
    关注

    SOLUTION:

    All this mess and in the end the problem was that one of the variables in my javascript were misspelled as 'ctheme' instead of 'theme'.

    And the blank email issue was resolved because I typed '$$body' instead of '$body'.

    Anyways, thanks every one for help, especially @KIKOSoftware

    P.S: I guess its a welcome to the world of programming.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?