0
Can ajax success redirect form posted to php directly
I have a form posted to php file with jquery ajax but i could not get the file type data. So i want to add the php file to the html action like this: <form method='post' action='image.php' enctype="multipart/form-data"> <input type='file' name='image' id='image' > </form> And still use ajax success function to redirect it after post
2 Réponses
+ 1
Yes.
Whether your JavaScript-generated HTTP request is uploading a file or not, you can get the same type of data in a response. You can then use the result to decide where to redirect to if something about the URL needs to come from the server.
You could run JavaScript like this to perform the redirect:
window.location.href = "http://www.w3schools.com";
This isn't what you asked but you can also submit the form using JavaScript and let the server redirect to another page by running something like this in PHP:
header('Location: yournewlocation.php');
JavaScript can submit the form without using AJAX. It can be submitted by running something like:
document.querySelector('form').submit();
0
Very help ill try using javascript