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

后端 未结 6 542
名媛妹妹
名媛妹妹 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:35

    Hi You can call the below function to perform this it loads the data from server on success you can create fail function as well

     function setValue(Id) {
     document.getElementById("digital_download").innerHTML = 
    "Downloading...Please be patient. The process can take a few minutes.";
     var data1 = {
            message: Id,
        };
    
        $.ajax({
          data: data1,
          type: 'GET',
          url: "http://urltoscript/index.php",
         cache: false,
            dataType: "json",
            crossDomain: true,
            success: function(data) {
            console.log("Response for cancel is: " + data);
    
         document.getElementById("digital_download").innerHTML =  data
    
          }
        });
    
     }
    

提交回复
热议问题