0

I am trying to redirect to another page and pass an array with it, I have tried the following:

$.post('search-results.php', {'results': results});

but nothing happens at all. No errors or anything, what am I doing wrong?

2 Answers 2

3

POST wont redirect it will however send your data there. Use window.location = URL for redirect in javascript

Sign up to request clarification or add additional context in comments.

Comments

1

Three solutions:

  1. fill a hidden form with post action and submit it via javascript.

  2. use window.location.url and add the parameters as get request but keep in mind that it's not post request as you wish.

  3. use jquery $.post, send the post data to a php script that keeping the data into session and on success callback redirect through window.location to the page that you want. This page will be looking if data exists in the session and it will use these data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.