I have a registration form and am using [jQuery][1] [Ajax][2] to submit it.
Here is the jQuery Ajax code:
$(document).ready(function() {
$("form#regist").submit(function() {
var str = $("#regist").serialize();
$.ajax({
type: 'POST',
url: 'submit1.php',
data: $("#regist").serialize(),
dataType: 'json',
success: function() {
$("#loading").append("<h2>you are here</h2>");
}
});
return false;
});
});
I have validation at submit1.php for email and username. When I submit the form with valid data it enters the database and if I enter some repeated data or invalid email it does not enter the database. So my submit1.php works fine.
My main problem is that the success function event at Ajax does not work.
**
Removing dataType:json did work and my success function event was called. However now i got another issue. In my submit1.php file i check for repeated email address , and username in db. If the email or username is repeated then an error needs to be generated to the user without page refresh. I have put a die() in my server script. how do i return this response at success event in ajax?? thanks..
**