lrony* 2013-09-16 00:56 采纳率: 0%
浏览 27

jQuery加载PHP

I'm building a website where I load new data into the page by making and ajax request to a PHP page which pulls new data and then appends it to the document. There is a vote counter that counts the number of votes. The only problem here is I'm using another load function to increase the number of votes.

Programmatically, it is as follows

$.ajax({
    url: 'load.php',
    type: 'POST',
    data: data,
    cache: false,
    success: function (data) {
      var json = jQuery.parseJSON(data);
      if (json.status == 'newcontent') {
        $('.loadafter').before(json.content)
      }
    });
$.ajax({
    url: 'voteup.php',
    type: 'POST',
    data: data,
    cache: false,
    success: function (data) {
      var json = jQuery.parseJSON(data);
      if (json.status == 'success') {
        $("#votecount"+).load("home.php #votecount" + postid);
      }

the problem the second ajax request does not work for the new content that has been added by the previous Ajax request

Edit:The variable postid is used to target the post which is being voted up

  • 写回答

1条回答 默认 最新

  • weixin_33726313 2013-09-16 01:38
    关注

    At a rough guess yout problem is $("#votecount"+).load("home.php #votecount" + postid);.

    $("#votecount"+) isn't a valid selector. Try fixing that.

    Also check what to you get when you call "home.php #votecount" + postid directly.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!