Anu
Anu

Reputation: 1129

Form submission not executing on an Ajax success page

I am using Ajax to display some content inside a form in my page that have an id of display as below

<form method="post"><div id="display"></div></form>

In the content that displayed by Ajax, there is a button named assign. I am using php to check if form submitted and if it is, then it will redirect to another page as below

if(isset($_POST['assign'])){
        header("Location: trial.php");
    }

But somehow it is not going to that page. Does anyone know what am I doing wrong here?

Edit 1

More explanation. From main page, using Ajax, I am directing to a php page where it echo some information including echo a button to main page. Those information will be showed in the main page in the display id. But when I press the button, form is not submitting

Upvotes: 0

Views: 42

Answers (1)

dearsina
dearsina

Reputation: 5192

That's not how AJAX works.

  • Open up the developer console (F12 in Chrome).
  • Click on the Network tab on top.
  • Click on your Assign button.
  • Find the row that was created when you pressed the button.
  • Click on the row, then click on the on the Response tab.

Do you see the HTML data you were expecting? If you want an AJAX response to change your current browser URL, you'll need to instead "send back" to the web page a response that tells your JS that it should force a URL change.

Upvotes: 2

Related Questions