The success data was successfully used in the jsonp, browser, but the Wechat development tool success did not execute it.

the cause of the problem: the company has two sites, a. Net cms system, and a Wechat official account system. I want to let the static pages of. Net be able to use the interface of js-sdk when Wechat shares them.

idea: then looked up on the Internet, the static page can use ajax combined with jsonp cross-domain request Wechat config data, in order to meet the requirements. The following is the front and back end code.

Front end a site:

< script src= " https://apps.bdimg.com/libs/j.;></script>

<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script>
    $(function(){
        var url=location.href;
        $.ajax({
            type : "get",
            url : "https://xxx&url="+url,//xxxconfig
            dataType: "jsonp",
            jsonp: "callback",
            jsonpCallback:"success_jsonpCallback",
            success : function(data){
                wx.config({
                    appId: data.appId,
                    nonceStr: data.nonceStr,
                    timestamp: data.timestamp,
                    signature: data.signature,

                    jsApiList: [
                      "onMenuShareTimeline", //
                      "onMenuShareAppMessage", //
                      "onMenuShareQQ", //QQ
                      "onMenuShareWeibo" //
                    ]
                });
                console.log("Response success");
             },
            error: function(xmlHttpRequest, textStatus, errorThrown) {
                console.log(xmlHttpRequest.responseText + "--------" + textStatus + "-------" + errorThrown);
            }
        });
        wx.ready(function (){
             var shareData = {
                 title: "",
                 desc: "",
                 link: "",
                 imgUrl: "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2370424667,3031767846&fm=26&gp=0.jpg"
             };
             wx.onMenuShareAppMessage(shareData);
             wx.onMenuShareTimeline(shareData);
             wx.onMenuShareQQ(shareData);
             wx.onMenuShareWeibo(shareData);
        });
    });
</script>

backend code:

global $_ W, $_ GPC;//$_GPC is understood as $_ GET, which is a collection of get, post, and cookie functions integrated into the framework.

$account_api = WeAccount::create ();

if (! $_ GPC ["url"]) {

$jssdk = $account_api->getJssdkConfig();

} else {

$jssdk = $account_api->getJssdkConfig($_GPC["url"]);

}

The final result of

/ * $jssdk is
array (

)
"appId" => "wxa73dbd97862b9758"
"nonceStr" => "bGklkTtbe84Ou6t4"
"timestamp" => "1514628503"
"signature" => "82b3c304af7f550520c3b3ab68ae4d3a7fcc88f9"

)
* /

$jssdk2 = json_encode ($jssdk);

$callback = $_ GPC ["callback"];

echo $callback. "(" .$ jssdk2. ")"; exit ();
? >

the problem now is:

I execute the front-end code that console.log ("Response success"); can be printed in a chrome browser. But in the browser of Wechat development tool, the content of error:function () {} is always printed:

undefined-parsererror-Error: success_jsonpCallback was not called

Jun.22,2021
Menu