我想在点击此按钮时运行我的php功能,这在Chrome和Firefox上运行正常,但在Safari上没有,我不知道原因:(请帮帮我......
我的PHP函数是:complete_automate_xml();
我的按钮是:<button id="btn" onclick="alertWithoutNotice();" class="deletebtn button button-next">Verstuur E-mails</button>
我的代码是:
<script>
jQuery(document).ready(function($) {
$('#btn').click(function(){
$.ajax({
type: "POST",
url: '../wp-admin/admin.php?page=spd_xml_importer',
data: {action: 'call_this'},
success: function (html) {
alert(html);
}
});
});
});
</script>
<div class="email-bt">
<script>function alertWithoutNotice(message) {
setTimeout(function () {
alert('E-mails zijn verzonden');
}, 300);
}</script>
<button id="btn" onclick="alertWithoutNotice();" class="deletebtn button button-next">Verstuur E-mails</button>
</div>
<?php
if ($_POST['action'] == 'call_this') {
complete_automate_xml();
}
答案 0 :(得分:0)
我的想法更像是这样 - 但我并不是100%确定这是Safari的问题我只是想知道浏览器中是否存在关于调用哪个函数的混淆。
<script>
jQuery(document).ready(function($) {
$('#btn').click(function(){
setTimeout(function() {
alert('E-mails zijn verzonden');
}, 300);
$.ajax({
type: "POST",
url: '../wp-admin/admin.php?page=spd_xml_importer',
data: { action: 'call_this' },
success: function (html) {
alert(html);
}
});
});
});
</script>
<div class="email-bt">
<button id="btn" class="deletebtn button button-next">Verstuur E-mails</button>
</div>