Ajax not redirecting me to next page

后端 未结 2 1876
予麋鹿
予麋鹿 2021-01-28 22:04

I am trying to pass the ID of the clicked image to next page. When I developed my code, it didn\'t redirect me to the next page. When I click F12 and check the POST in network,

2条回答
  •  不思量自难忘°
    2021-01-28 22:44

    The entire point of Ajax is that that request is made with JavaScript and the response is handled by JavaScript without navigating to a new page.

    If you want to make a POST request and navigate to the resulting page, then use a


    window.location.href = 'userevent.php';
    

    it redirect me but without the variable

    Assigning a URL to location.href triggers browser navigation (with a GET request) to that URL.

    It is a completely different request to the Ajax request so it doesn't have the data from that request.

    Again: Use a form for this.


    I read the data from database and I get the clicked id of the images.

    Put the data you want to send in a submit button instead.

    
        fetch_assoc())  ?>
            
        
     
    

提交回复
热议问题