0

I have form that when submitted it uses AJAX and its posts data to reg1.php. I want it to do some bits with the data posted and then redirect to a page to use it.

When I redirect after how do I post the posted data with it to list.php?
Or is there another way of doing it?

<script>
$(document).ready(function () {
  $(".loginform").submit(function() {
    data = $("#loginform").serialize();
    $.ajax({
      type: "POST",
      url: "reg1.php",
      data: data,
      success: function(result) {
          if (result == 'success') {

            //$('.output_message').text('Message Sent!');
            //$('#loader').hide();
            alert("SUCCESS");
                window.location.replace("list.php");
          } else {
            //$('.output_message').text('Error Sending email!');
            alert("NO SUCCESS");
            //$('#loader').hide();
          }
      }
    });

    return false; 
  });
});
</script>
Tryliom
  • 895
  • 1
  • 12
  • 37
wayneuk2
  • 156
  • 1
  • 10
  • `window.location.replace("list.php?key1=val1&key2=val2");` and on a new page you can get it params. You can see this question: https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters – Vasyl Zhuryk Jul 24 '18 at 13:11
  • ok thanks, can I just add the data = $("#loginform").serialize();??? – wayneuk2 Jul 24 '18 at 14:44
  • 3
    if you're just going to redirect when the ajax is completed, what's the reason for using ajax? the whole point of ajax is to stay on the same page. You could just use a standard postback and save yourself some code. – ADyson Jul 24 '18 at 14:45

0 Answers0