简体   繁体   English

jQuery POST数据未发送

[英]jQuery POST data not being sent

For some reason the data skip is not being sent through: 由于某些原因,数据skip没有通过以下方式发送:

main.php main.php

  var skipCounter = 0;

  $('#load-more-comments').click(function(){

    skipCounter++;
    postid = <?php echo $_GET['t']; ?>;

    $.ajax({
      method: 'POST',
      url: 'morecomments?t='+postid+'.php',
      data: {skip:skipCounter},
      success: function(data){
        $('.comments-main').append(data);
      }
    });
  });

morecomments.php morecomments.php

$skip = mysqli_real_escape_string($conn,$_POST['skip']);
$postid = mysqli_real_escape_string($conn,$_GET['t']); 

$skip is null I believe, as when I manually set it to 1 instead of through POST data my code (beneath) works. 我相信$skip为null,因为当我手动将其设置为1而不是通过POST数据时,我的代码(在下面)有效。 The actual request is successful though. 实际的请求是成功的。

What can cause this? 是什么原因造成的?

url should be 'morecomments.php?t=<....> instead of 'morecomments?t=<....>.php url应为'morecomments.php?t=<....>而不是'morecomments?t=<....>.php

Even though you have a .htaccess that removes the .php part, it is still an invalid URL and that means that the rewrite might be removing more than you want, or the server is just rejecting part of it all together. 即使您有一个.htaccess删除了.php部分,它仍然是无效的URL,这意味着重写可能会删除比您想要的更多的内容,或者服务器只是一起拒绝了一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM