Update dynamically a page through ajax and php

后端 未结 3 784
庸人自扰
庸人自扰 2021-01-26 23:00

I want to submit data through ajax to the database and after inserting data into database this data should be displayed on the file Demo.html dynamically at t

3条回答
  •  醉酒成梦
    2021-01-26 23:38

    It's based on answer from @Nikhil Nanjappa.

    You can use an array to store more items in localStorage. Store object in localStorage.

    AjaxFile.html

    success: function(msg) {
      document.getElementById('get').innerHTML = msg;
    
      StoredData = JSON.parse(localStorage.getItem("StoredData"));
      if(!StoredData) StoredData = [];
      StoredData.push(myData1);
      StoredData.push(myData2);
      localStorage.setItem("StoredData", JSON.stringify(StoredData));
    
      window.location.href = 'Demo.html'
    }
    

    Demo.html (At the bottom of the body)

    
    

提交回复
热议问题