我希望您能在pug模板文件中发送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'
});
})()
但是它没有起作用,该怎么办? 我想知道如何在pug文件的嵌入式JavaScript中发送ajax请求