在贴代码之前,说明一下:我用的是php7.1
第一步:在前端html里面,设置一个iframe。<iframe src="" id="payw" width="0" height="0" sandbox="allow-scripts allow-top-navigation allow-same-origin"></iframe>
第二步,当点击支付按钮的时候,调用js代码。
$("#btnsure").click(function(e){
$.ajax({
type: "post",
url: "/member/index/pay.html",
data: { je:$('input:radio[name=fee]:checked').val() },//je代表金额
dataType: 'JSON',
success: function (datak) {
layui.use(['layer'], function () {
var layer = layui.layer;
layer.ready(function () {
switch(datak.code){
case 1: