?php foreach($participants as $participant) {
echo "<tr>";
echo "<td>" . $participant['Vorname'] . "</td>";
echo "<td>" . $participant['Auto'] . "<img id=$participant[name_id] onclick='deleteDriver()' class='delete' src='img/tonne.gif' align='right' data-url='backend/queries.php?decision=deleteDriver&id=".$participant['name_id']."'/></td>";
echo "</tr>";
}
?>
function deleteDriver()
{
var dataString = "decision=deleteDriver";
$.ajax({
type: 'POST',
url: 'queries.php',
data: dataString
}
})
}
</script>
当我按下按钮时,不会调用该功能。为什么呢?
答案 0 :(得分:1)
formTargetUrl := "www.someVendor.com"
formMethod := "POST"
fromData := "exampleKey=exampleValue&email=me@something.com&foo=bar"
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HttpObj.Open(formMethod,formTargetUrl)
HttpObj.Send(fromData)
rawHtmlResponse := HttpObj.ResponseText
;now you could use regex to find the text,
;you could also dump rawHtmlResponse to a text file,
;or you could use the HTMLfile object if you can identify the html element by its id, name, class, tagname, etc.
document := ComObjCreate("HTMLfile")
document.write(rawHtmlResponse)
textElement := document.getElementById("someId")
;you may also try:
;textElement := document.getElementsByName("someName")[1] ;returns multiple results (not sure if 1 or 0 is the first result)
;textElement := document.getElementsByTagName("someTagName")[1] ;returns multiple results (not sure if 1 or 0 is the first result)
;textElement := document.getElementsByClassName("someClassName")[1] ;returns multiple results (not sure if 1 or 0 is the first result)
MsgBox % textElement.innerText
;you may also try
;MsgBox % textElement.textContent
;MsgBox % textElement.innerHTML
;MsgBox % textElement.value
之前您错过了<script>
开放代码。请添加并重试。请尝试以下方法:
function deleteDriver()
答案 1 :(得分:1)
尝试使用此代码。
<?php
foreach($participants as $participant) {
echo "<tr>";
echo "<td>" . $participant['Vorname'] . "</td>";
echo "<td><a onclick='deleteDriver()'>" . $participant['Auto'] . "<img id=$participant[name_id] class='delete' src='img/tonne.gif' align='right' data-url='backend/queries.php?decision=deleteDriver&id=".$participant['name_id']."'/></a></td>";
echo "</tr>";
}
?>
<script>
function deleteDriver()
{
var dataString = "decision=deleteDriver";
$.ajax({
type: 'POST',
url: 'queries.php',
data: dataString
})
}
</script>