Javascript POST not working - Sending Javascript array to PHP

前端 未结 4 676
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 08:05

I know there a fair few entries on SO and the web on this however I just can\'t get to work - any help would be appreciated.

So i have an array in Javascript which I

4条回答
  •  爱一瞬间的悲伤
    2020-11-27 08:32

    This is what happens when you open your page (index.php)

    1. A GET request is issued to index.php and the content is returned. There are no values in the $_POST array so your print_r() line does nothing.
    2. Javascript is executed that sends a POST request to index.php via AJAX. Note that this is an entirely new request, separate to the original GET. The $_POST array will be populated on this request however the response is discarded.

    Hopefully this will illustrate what you can do.

    ajax.php

    index.php

    
    

提交回复
热议问题