我有一个 HTML 表单。提交表单时,我想将数据发送到 IFTTT webhook。我尝试了两个选项,但似乎它们不起作用。
HTML 提交按钮:
<li class="buttons"><input name="klantnummer" type="hidden" value="1234567890" />
<button onclick="sendToIFTTT123()">Verstuur</button></li>
第一个代码:
<script> function sendToIFTTT123(){
var url = "https://maker.ifttt.com/trigger/[event]/with/key/[key]";
var text = {"value 1" : document.getElementById("element_2_1").value + " - " + document.getElementById("element_2_2").value + " - " + document.getElementById("element_2_3").value};
$.ajax({
data: 'payload=' + JSON.stringify({
"text": text
}),
dataType: 'json',
processData: false,
type: 'POST',
url: url
});
}
</script>
第二个代码:
<script>
function sendToIFTTT() {
var content = {"value1" : document.getElementById("element_2_1").value + " - " + document.getElementById("element_2_2").value + " - " + document.getElementById("element_2_3").value};
var url = "https://maker.ifttt.com/trigger/[event]/with/key/[key]";
var options = {
"method" : "post",
"contentType" : "application/json",
"payload" : JSON.stringify(content)
};
return UrlFetchApp.fetch(url, options);
}</script>
有谁知道谁让这个工作?