I am using a HTML form to submit to a jQuery validation which then sends information to a PHP processing page through ajax.
Everything works 100% apart from when everything comes back true I can't get the page to redirect to a success page.
The code I have is:
$.post(url,{ username: value_login.val(), firstname: value_firstname.val(), lastname: value_lastname.val(), email: value_email.val(), password: value_password.val()} , function(data) {
if(data == 'success'){
window.location.href = "http://example.com/Registration/Success/";
} else {
$('#error').text('error');
}
});
I'm thinking you can't redirect using the window.location.href
function.
How to Redirect to Another Page in HTML. To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page. The <head> section of an HTML document contains metadata that is useful for the browser, but invisible to users viewing the page.
Answer: Use the JavaScript window. location Propertylocation property to make a page redirect, you don't need any jQuery for this. If you want to redirect the user from one page to another automatically, you can use the syntax window. location. replace("page_url") .
You forgot the HTTP part:
window.location.href = "http://example.com/Registration/Success/";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With