JS 操作 HTML 和 AJAX 請求后台數據


為某個元素插入值,添加屬性,添加子元素

  1 <div class="col-sm-6">
  2    <select class="form-control" id="creategood_store">
  3    </select>
  4  </div>
  1  var parent = document.getElementById("creategood_store");
  2  var node = document.createElement("option");
  3  node.setAttribute("value", data.result[i].id);
  4  node.innerHTML = data.result[i].name;
  5  parent.appendChild(node);

AJAX 請求后台數據

  1   $(document).ready(function () {
  2         $.ajax({
  3             url: "/gankadc/home/newlydata/recordlist",
  4             type: "GET",
  5             dataType: "json",
  6             success: function (data) {
  7 		...
  8 	    }
  9 
 10         })
 11     });
 12 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM