Javascript Sweetalert2 Swal.mixin-是否可以将输入数据提取到json/php? `, confirmButtonText:“可爱!” }) } })
在这种情况下,我的答案是:Javascript Sweetalert2 Swal.mixin-是否可以将输入数据提取到json/php? `, confirmButtonText:“可爱!” }) } }),javascript,php,arrays,json,sweetalert2,Javascript,Php,Arrays,Json,Sweetalert2,在这种情况下,我的答案是: Using this code: Swal.mixin({ input: 'text', confirmButtonText: 'Next →', showCancelButton: true, progressSteps: ['1', '2', '3'] }).queue([ { title: 'Question 1', text: 'Chaining swal2 modals is easy' }, '
Using this code:
Swal.mixin({
input: 'text',
confirmButtonText: 'Next →',
showCancelButton: true,
progressSteps: ['1', '2', '3']
}).queue([
{
title: 'Question 1',
text: 'Chaining swal2 modals is easy'
},
'Question 2',
'Question 3'
]).then((result) => {
if (result.value) {
const answers = JSON.stringify(result.value)
Swal.fire({
title: 'All done!',
html: `
Your answers:
<pre><code>${answers}</code></pre>
`,
confirmButtonText: 'Lovely!'
})
}
})
["1","1","2"]
它如何接收这些值传入一个php文件?
我不太了解这两个主题,但我正经历着这种需要。
对不起,对不起我的英语。更新:
使用此代码:
为消防队更换消防队
var strAns1;
var strAns2;
swal.mixin({
input: 'text',
confirmButtonText: 'Next →',
showCancelButton: true,
progressSteps: ['1', '2', '3']
}).queue([
{
title: 'Question 1',
text: 'Chaining swal2 modals is easy',
preConfirm: function(value)
{
strAns1= value;
}
},
{
title: 'Question 2',
text: 'Chaining swal2 modals is easy',
preConfirm: function(value)
{
strAns2= value;
}
}
]).then((result) => {
if (result.value) {
Swal.fire({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
现在我可以把它传递给php吗?
比如说?
非常感谢。如果我理解正确,您在
php
文件中有数据,并且您希望在js代码中获取数据,因此您需要使用ajax
搜索it@Joseph事实上,我想把这些数据从代码中传递到PHP。我只是不太明白怎么做。你能指引我吗?我搜索了这个,发现了这个帖子:没有任何决议。
swal({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
To
Swal.fire({
title: 'All done!',
html:
'Your answers: <pre>' +
JSON.stringify(result) +
'<pre>Answer1- ' + strAns1+
'<pre>Answer2- ' + strAns2+
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
{"value":["adf","fffff"]}
Answer1- adf
Answer2- fffff