ajax post not sending data

后端 未结 2 507
我在风中等你
我在风中等你 2021-01-25 08:54

UPDATE: I Figured it out. Was a URL issue, which redirected and cleared the POST before it was sent to the server.

$(\'#addbtn\').on(\'click\',function() {

$.a         


        
2条回答
  •  礼貌的吻别
    2021-01-25 09:23

    If GET request works but POST doesn't it's most usually the issue with redirect. That said, while the request initially accessed the first URL and got redirected to another URL then all the POST data were not forwarded along to another URL. Therefore all the data gets lost.

    Some common cases that might occur (depending on server configuration):

    • "/method/" might get redirected by your site to "/somethingCompletelyElse/"
    • "/method" might get redirected by your site to "/en/method" (language redirect)
    • "method/" might get redirected by your site to "method"
    • "method" might get redirected by your site to "method/" (common, extra backslash)
    • "example.com/method" might get redirected by your site to "www.example.com/method"

    You get the idea. If you look in network panel and notice that there is no data sent but response was 200 OK then it's good idea to check if Request URL in network panel is the one that you specified in your code. Although this will be possible only in modern browsers. In older browsers you won't even know that URL has been redirected.

    For Example (see that "en/" is missing in my request url): enter image description here

提交回复
热议问题