【发布时间】:2018-07-23 12:25:41
【问题描述】:
我对 ajax 有疑问,我正在努力学习它,但他不想要我 :)
这是我的代码:
<script>
$('._givePP').on('click', () => {
swal.mixin({
input: 'text',
confirmButtonText: 'Next →',
showCancelButton: true,
progressSteps: ['1', '2']
}).queue([
{
title: 'Question 1',
text: 'Chaining swal2 modals is easy'
},
{
title: 'Question 2',
text: 'bla bla 2'
}
]).then((result) => {
if (result.value) {
$.ajax({
_dapepe: true,
url: '<?php echo Config::$data->url;?>action/profile',
type: 'POST',
success: (e) => {
e = JSON.parse(e);
swal({
title: e.title,
text: e.message,
type: e.type
});
}
});
}
})
});
</script>
这是 php 代码:
<?php
if(isset($_POST['_dapepe'])) {
return print_r(json_encode(array('title' => 'Success','text' => 'gg','type' =>'success')));
}
?>
我想要得到的只是一个简单的 gg 文本,所以我知道它正在读取 php 文件,但我没有收到 gg 消息。有谁知道出了什么问题或为什么它不读取文本?
顺便说一句,我验证了它的工作网址。
【问题讨论】:
-
另外,
$('._givePP').on('click'...应该真正包裹在.ready... 因为它在静态父动态模式下不使用.on。
标签: php ajax sweetalert2