SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery.ajax() and my problem?

    hello
    why this code not work?
    html:
    Code:
    <div id="connect">
                        <form accept="" method="POST">
                           name: <input type="text" name="name"><p></p>                        
                           email: <input type="text" name="email"><p></p>
                            tell: <input type="text" name="phone"><p></p>
                           text:<p></p>
                            <textarea name="text"></textarea>
                            <input type="submit" name="submit" id="submit" value="send">
                        </form>
                        </div>
    jquery:
    Code:
    $(document).ready(function(){
        // do stuff when DOM is ready
        $("#menu, #main, #form_connect, #talk_admin,").css("border-radius", "5px");
        
        $("#submit").click(function(){
            var name = $("input#name").val();
            var email = $("input#email").val();
            var phone = $("input#phone").val();
            var text = $("input#text").val();
            var dataString = 'name=' + name + '&email=' + email + '&phone=' + phone + '&text=' + text;
            //alert (dataString);return false;
            $.ajax({
                type: "POST",
                url: 'http://localhost/zig-co/index.php/home/connect',
                data: dataString,
                cache: false,
                success: function(){
                    $('#connect').html("<div id='message'></div>");
                    $('#message').html("<h2>Contact Form Submitted!</h2>").append("<p>We will be in touch soon.</p>").hide().fadeIn(1500, function(){
                        $('#message').append("ok");
                    });
                }
            });
            return false;
        })

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by binboy View Post
    why this code not work?
    Because it's not doing what you expect.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •