<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#put').click(function(){ //button按下時觸發
var cart = $('#cart').val(); //id name value
var qty = $('#qty').val(); //id name value
$.ajax({
type: "POST",
url: "update.php",
data: {type:""+cart+"",product_qty:""+qty+""},
success: function(data){
//if sucess do something
alert(data); //查看從update.php帶回的資料
}
});
});
});
<script>
簡化 $(document).ready(function(){ 寫法
$(document).ready(function(){
//do something
});
$().ready(function(){
//do something
});
$(function(){
//do something
});
沒有留言:
張貼留言