我想在帕格模板文件中發送Ajax請求。如何在帕格模板中發送Ajax請求?
form#payment-form()
section
label(for="amount")
input#amount(name="amount" type="tel" min="1" placeholder="Amount" value="10")
script(src="scripts/jquery.js")
script.
(function() {
var amount = $('#amount').val();
$.ajax({
type: "POST",
url: "/posturl",
data: {'amount':amount},
success: function(){},
dataType: 'json'
});
})()
但它不起作用,該怎麼辦呢? 我想知道如何在哈巴狗文件內嵌的JavaScript發送Ajax請求