How to load a PHP page into a div with jQuery and AJAX?

后端 未结 6 543
名媛妹妹
名媛妹妹 2021-02-03 13:58

I am trying to write a function that will call getproduct.php?id=xxx when clicked. I can get the innerHTML portion to appear, but how do I also call t

6条回答
  •  梦如初夏
    2021-02-03 14:46

    You can do it with jQuery for example.

    var id = 1;
    $('#digital_download').html('Downloading...'); // Show "Downloading..."
    // Do an ajax request
    $.ajax({
      url: "getproduct.php?id="+id
    }).done(function(data) { // data what is sent back by the php page
      $('#digital_download').html(data); // display data
    });
    

提交回复
热议问题