/    Sign up×
Community /Pin to ProfileBookmark

submit form with jquery

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’);
});
});

[/code]

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

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @rezzy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...