执行后的 PHP Curl 不返回 Ajax 请求

我正在集成一个 PHP 代码来将站点地图 ping 到谷歌和 Bing。代码执行完美,但如果我从 ajax 调用发起请求,那将是事实。它不会返回


下面是我用来进行 ajax 调用的 Jquery 代码


$("body").on('click', 'button#sitemap_google_submit', function(event){

    toastr.info("Would require few seconds, Please wait, do not refresh Page..",

                "Submitting Sitemap to Google!",

                {   progressBar:!0,

                    showMethod:"slideDown",

                    hideMethod:"slideUp",

                    timeOut:2e3,

                    preventDuplicates: true,

                    positionClass: "toast-bottom-right"

                }

            );

    $("button#sitemap_google_submit").attr("disabled", true);

    $("button#sitemap_google_submit").html("<i class='ft-loader spinner'></i> &nbsp;Submitting to Google..");


    $.ajax({

            url: '/bypasser/modules/seoController.php',

            type: 'POST',

            dataType: 'JSON',

            data: {type: 'submit', console: 'google'},

        })

        .done(function(resp) {

            $("button#sitemap_google_submit").attr("disabled", false);

            $("button#sitemap_google_submit").html("<i class='fa fa-google fa-lg'></i> &nbsp;Submit to Google");

            toastr[resp.type](resp.message, 

                              resp.heading,

                    {   showMethod:"slideDown",

                        hideMethod:"slideUp",

                        preventDuplicates: true,

                        positionClass: "toast-bottom-right"

                    });

        });

    });


JSON 编码在检查元素的网络选项卡的预览面板中完美显示,但不知何故它不返回对 ajax 的响应,这是什么问题?


慕斯王
浏览 146回答 1
1回答

SMILET

放curl_setopt($ch,&nbsp;CURLOPT_HEADER&nbsp;,&nbsp;false);&nbsp;&nbsp;//&nbsp;we&nbsp;don't&nbsp;want&nbsp;headers代替curl_setopt($ch,&nbsp;CURLOPT_HEADER&nbsp;,&nbsp;true);&nbsp;&nbsp;//&nbsp;we&nbsp;want&nbsp;headers我们也不需要标头,据我了解您的问题,您可能只是在寻找 ping 状态代码!
打开App,查看更多内容
随时随地看视频慕课网APP