0

Whenever I try to run this script it say "Unexpected token ILLEGAL"

<form name="abc" id="fform" class="contactform">
                    <p>
                    <label for="name">Name:</label><br /><input type="text" name="name" id="name" value="" class="input" /> <br/>
                    <label for="email">Email:</label><br /><input type="text" name="email" id="email" value="" class="input" /> 
                    </p>
            <input name="send" id="submit_btn" class="submit_btn"  type="submit" value="Join" />
                </form><!--end contact form-->
                <script>
                $(document).ready(function(){
                    $(#fform).submit(function() {
                    alert("asd");
                });
});
    </script>

I am trying to create a function that when I click on submit it creates an ajax call to insert values into the database.

2
  • This is what syntax highlighting is for. See the string in alert is red? The parameter of your jQuery selector should be a string, and so it should be red too. Commented Feb 22, 2014 at 14:40
  • where is your ajax code Commented Feb 22, 2014 at 15:03

1 Answer 1

2

You need to wrap your id in quotes:

$(document).ready(function(){
    $('#fform').submit(function() {
// ---^ here ^ ----------
        alert("asd");
    });
});
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.