Ajax form submit problems

I’m trying to submit a form using ajax and got it working just fine but 1 problem though…

I want my submit button to have another value than “Submit”, lets say “Next”, but if I change this the form is not submitted… Where do I go wrong?

$(function() {
$(".submit").click(function() {
var address1 = $("#address1").val();
var zipcode = $("#zipcode").val();
var city = $("#city").val();
var cellphone = $("#cellphone").val();
var phone = $("#phone").val();

var dataString = 'address1='+ address1 + '&zipcode=' + zipcode + '&city=' + city + '&cellphone=' + cellphone + '&phone=' + phone;

if(address1=='' || city=='')
{
$('.success').fadeOut(200).hide();
$('.error').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "update.php",
data: dataString,
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}
});
}
return false;
});
});

Thanks in advance :slight_smile:

None of that code appears to be relevant to the problem at hand.

What is the HTML code that causes things to fail, and do you have any code anywhere that makes uses the submit button value?

Here is the form:

<form action="" method="post">
Address1: <input id="address1" name="address1" type="text" /><br />
Zipcode: <input id="zipcode" name="zipcode" type="text" /><br />
City: <input id="city" name="city" type="text" /><br />
Cellphone: <input id="cellphone" name="cellphone" type="text" /><br />
Phone: <input id="phone" name="phone" type="text" /><br />
<input type="submit" value="Submit" class="submit"/>
</form>

<div>
<span class="error" style="display:none"> Please Enter Valid Data</span>
<span class="success" style="display:none"> Registration Successfully</span>
</div>

Its if I change “<input type=“submit” value=“Submit” class=“submit”/>” to “<input type=“submit” value=“Test” class=“submit”/>” it goes wrong???

That’s very odd. I cannot duplicate the problem with my own test code, so the next step from here is for you to link us to a live test page that exhibits the problem you’re having.

My bad… Had a line in my script without the “;” afterwards… Everything works just fine:-)