0

This should be easy, I just cant catch what's the problem for almost an hour so maybe I'm missing something.

I want to create a responsive contact form without a "thank you" page, so I am using ajax.

I wrote all the code, this is my responce I get on my console:

Uncaught RangeError: Maximum call stack size exceeded

that keeps running infinitely.

This is my form:

    <div id="contactform" style="position: relative; top: 180px; left: 50px;">
        <table width="600px" class="contactform" >

            <tr>
                <td colspan="2">  Full Name: <br/> </td>
                <td colspan="2"> <input type="text" id="fullname" />   </td>    
            </tr>


            <tr>
                <td colspan="2">  Phone Number: </td>
                <td colspan="2"> <input type="text" id="telephone"/> </td>
            </tr>


            <tr>
                <td colspan="2">  Email Adress: </td>
                <td colspan="2"> <input type="text" id="email"/> </td>
            </tr>


            <tr>
                <td colspan="2"> Subject: </td>
                <td colspan="2"> <input type="text" id="subject" /> </td>
            </tr>

            <tr>
                <td colspan="2"> Content: </td>
                <td colspan="2"> <textarea rows="5" cols="50" id="text"> </textarea> </td>
            </tr>

            <tr>
                <td colspan="2">  </td>
                <td colspan="2"> <input type="button" class="link" value="Send" id="sendBtn" /> </td>
            </tr>
        </table>
    </div>      

this is my ajax code part from the .js file:

$('#sendBtn').click(function(){
    //get info 
    console.log("dude!");
    var fullname = $("#fullname").val();
    var telephone = $("#telephone").val();
    var email = $("#email").val();
    var subject = $("#subject").val();
    var text = $("#text").val();
    //send info to php 
    $.ajax({
        beforeSend: function() {
    //      $("#spin").html(spiner);
        },
        url: 'http://www.example.com/MYtest/contact.php', 
        type: "POST", 
        data: ({ "fullname": fullname, "telephone": telephone, "email": email, "subject": subject, "text": text }), 
        success: function (results){
    //      $("#spin").hide(spiner);
            console.log(email);

            //hide table 
            $('#contactform').hide('slow', function() {
                // Use arguments.callee so we don't need a named function
                $('#contactform').hide( "slow", arguments.callee );
              });
            //show textboxes
            $('#aboutSuccess').show("slow");
        }
    }); 


});

and this is my content.php :

    if(isset($_POST['email'])) {
        $email_to = "[email protected]";
        $email_subject = "You have a new email from example.com";

        $fullname = $_POST['fullname'];
        $telephone = $_POST['telephone']; 
        $email = $_POST['email'];       
        $subject = $_POST['subject'];   
        $text = $_POST['text'];     

        $message = "Full Name: ". $fullname ."\n Telephone: ". $telephone ."\n Email: ". $email ."\n Subject: ". $subject ."\n \n Message: \n". $text;

        mail($email_to, $email_subject, $message);
    }
2
  • 1
    I would guess it is the $('#contactform').hide( "slow", arguments.callee ) which might call arguments.callee immediately when the element is already hidden. Why do you want to use arguments.callee at all? Commented Nov 24, 2014 at 13:46
  • Your recursive hide table callback is the problem. I'm not sure what you were trying to accomplish there. Commented Nov 24, 2014 at 13:47

1 Answer 1

1

You are calling arguments.callee inside the function. That's what causing the loop.

$('#contactform').hide('slow', function() {
    // Use arguments.callee so we don't need a named function
    $('#contactform').hide( "slow", arguments.callee );
});

I don't get what you are trying to do with this code, maybe it's leftovers. Try replacing it with:

 $('#contactform').hide('slow');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.