dongleman4760
dongleman4760
2017-08-10 07:02
浏览 51

在php和ajax代码中的Jquery ajax问题

Here in the following code in jquery i get the alert test1 but when i try to get alert test2 i dint got that... there is some issue in code please help me to resolve.

$(document).ready(function() {
  $(".delete-item-details").click(function() {
    alert('test1');
    var id = $(this).attr('ids');
    alert('test2');
    var order_id = $("#order_id").val();

    goto_url = "/order/DeleteOrderDetailItems/" + id;
    dataString = 'id=' + id + '&order_id=' + order_id;
    $.ajax({
      type: "POST",
      url: goto_url,
      data: dataString,
      cache: false,
      success: function(html) {
        $("#row-id-" + id).fadeOut();
        $("#total_span").html(html);
      }
    });
  });
});
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongsunny1113
    dongsunny1113 2017-08-10 07:04
    已采纳

    Please change this three lines in code and you will definitely get alert !!

    alert('test1');
                    var id=$(this).attr('id');  // here you have written ids
    alert('test2');
    

    The default attribute is 'id' not 'ids'

    If still now clear let me know i will help you out.

    点赞 评论
  • duanfuchi7236
    duanfuchi7236 2017-08-10 07:08

    TRY var id = $(this).prop('ids');

    点赞 评论

相关推荐