I have problem using Jquery $.post to check data without refresh the page and print out any error on page div
I can’t header(location); to next page if all data are correct.
<script type="text/javascript">
function get(){
$('#error').hide();
$.post('./parts/signup_data.php',
{firstname:signup.firstname.value, lastname:signup.lastname.value,
email:signup.email.value, re_email:signup.re_email.value,
password:signup.password.value, re_password:signup.re_password.value,
age:signup.age.value,
gender:$('input:radio[name=gender]:checked').val(),
},
function(output){$('#error').html(output).fadeIn(50);}
)
}
</script>
Page will check all data without refresh and print out error on div tag
if all data are correct. it will insert the data into DB
mysql_query("INSERT INTO temp_user (email, password, firstname, lastname, age, gender, date, confirm_code)VALUES ('$email','$password','$firstname', '$lastname', '$age', '$gender', '$date', '$confirm_code')");
header('Location:confirm.php');
the problem is the page didn’t head to next page.
it print out all page’s information in div tag
You need to send something (eg, a JSON object) back to the Javascript code that tells it which page to go to.
The Javascript code in the success callback would then check the result from the server to see if it’s a URL or an error message, and set
location.hrefor display the message as appropriate.