Is it possible to redirect the page with PHP after an Ajax call?

后端 未结 4 771
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 03:57

I have a website where I want to provide an option for users, if they click on a table\'s rows, they get regirected to another page (based on the contect of the table row).

4条回答
  •  青春惊慌失措
    2021-01-29 04:34

    I basically want to get the id from the row and when the visitor clicks on the row, they should land on example.php?id=XXXXX

    You can do so entirely from PHP. When you generate the table, in each row (whose id we'll call XXXX to follow your example) you can include a link to example.php?id=XXXXX, or an onclick event for the whole row that executes window.location.href = 'example.php?id=XXXXX';. So your table might look like:

    ...
    
      1234some valuesome other value
    
    
      1235some valuesome other value
    
    ...    
    

    It could be done a little nicer by generating the rows with javascript and using event listeners, but this should work.

提交回复
热议问题