Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
submit form with jquery
Old 10-27-2009, 12:32 PM submit form with jquery
rezzy's Avatar
Super Talker

Posts: 115
Location: in the interwebz
Trades: 0
I am working on a form to submit contact information i have it set to echo what the jquery sees and its showing [object object].

Code:
$(document).ready(function()
{
    $("#contact").submit(function()
    {
        //remove all the class add the messagebox classes and start fading
        $("#msgbox").removeClass().addClass('messagebox').text('Submitting').fadeIn(1000);
        //check the username exists or not from ajax
        $.post("template/ajax_contact.php",{ name:$('#name'),email:$('#email'),number:$('#number'),comments:$('#comments'),sample:$('#sample') } ,function(data)
        {
      if(data=='passed') //if correct login detail
          {
              $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
            {
              //add message and change the class of the box and start fading
              $(this).html('Logging In').addClass('messageboxok').fadeTo(900,1,
            function()
          {
                   //redirect to secure page
                 document.location='success.php';
              });

            });
          }
            
if(data=='spam') //if correct login detail
                {
                $("#msgbox").fadeTo(200,0.1,function()
                                                     {
                                                        $(this).html('We believe you are not a person').addClass('messageboxerror').fadeTo(900,1); 
                                                     });
                    
                }

if(data=='error') //if correct login detail
                {
                $("#msgbox").fadeTo(200,0.1,function()
                                                     {
                                                        $(this).html('We believe you are not a person').addClass('messageboxerror').fadeTo(900,1); 
                                                     });
                    
                }


        else
          {
              $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
            {
              //add message and change the class of the box and start fading
          $(this).html(data).addClass('messageboxerror').fadeTo(900,1);
            });
          }
        });
         return false; //not to post the  form physically
    });
    //now call the ajax also focus move from
    $("#password").blur(function()
    {
        $("#contact").trigger('submit');
    });

});
Can anyone help straighten this out? Also do you need the form and php code behind this?
__________________

Please login or register to view this content. Registration is FREE

Resnodesigns
rezzy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-27-2009, 12:45 PM Re: submit form with jquery
spyderwebtech's Avatar
Skilled Talker

Posts: 51
Trades: 0
where is the alert?

I also noticed you are using $("#email") to collect the value for your fields (i believe). $("#email") returns a jQuery object while $("#email").val() returns the value of the input field with an ID of email.

this should also be in the javascript section not PHP

Last edited by spyderwebtech; 10-27-2009 at 12:47 PM.. Reason: extra comments
spyderwebtech is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to submit form with jquery
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09403 seconds with 12 queries